美文网首页
Vue中data选项组织数据

Vue中data选项组织数据

作者: leslie1943 | 来源:发表于2020-07-06 15:11 被阅读0次

    如果有rules,大量的model推荐使用下面的方式组织data数据

    export default{
      data(){
         const model = {
          username: 'suzhen',
          password: '12345678'
        }
         const rules = {
            username: [
            { required: true, message: 'Username is required' },
            { min: 2, max: 16, message: 'Username must be between 2 and 16 characters'       
            }],
          password: [
            { required: true, message: 'Password is required' },
            { min: 4, max: 16, message: 'Password must be between 4 and 16 characters' }
            ]}
        // 加上页面数据 
        return { model, rules, error: null, loading: false }
    }
    

    相关文章

      网友评论

          本文标题:Vue中data选项组织数据

          本文链接:https://www.haomeiwen.com/subject/pfnwqktx.html