Code Monkey home page Code Monkey logo

Comments (1)

609067409 avatar 609067409 commented on May 23, 2024 5

this.formData是有双向绑定的,你看this对象上formData有劫持到get set方法就可以排除
没有出现响应式的原因是因为render.js-18行代码
dataObject.props.value = defaultValue
其实就是相当于 <input v-model="defaultValue"> 正常来说应该是<input v-model="formData.mobile"> 才对,作者这里这样写是为了让默认值能出现在input上,但是这样也导致了你直接修改formData它无法回显的问题。
所以要修改这个问题也很简单,在兼容之前的代码基础上:
1将formData传入render.js

//render.js
 props: {
    conf: {
      type: Object,
      required: true
    },
++    formData: {
++     type: Object
++ }
  }

2.将<input v-model="defaultValue"> 改为<input v-model="formData.mobile"> 并且兼容之前的代码

// 注意这里要加一个参数获取vModel
//render.js-53行:
++vModel.call(this, dataObject, confClone.__config__.defaultValue, confClone)
//render.js-17行:
++function vModel(dataObject, defaultValue, conf) {
++   dataObject.props.value = this.formData ? this.formData[conf.__vModel__] : defaultValue
       dataObject.on.input = val => {
    this.$emit('input', val)
  }
}

3.在Parse.vue-28将formData传入给render.js使用
Parse.vue-28
++ <render conf={scheme} on={listeners} formData={this[this.formConf.formModel]}/>

然后再测试一下,你就会发现,好使了。

from form-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.