小编Map*_*Dev的帖子

通过 REST 加载表单数据到 vue-form-generator

我正在构建一个表单,它需要通过加载表单时需要发出的 JSON 请求动态获取数据。我看不到加载此数据的方法。这里有人可以帮忙吗?

JSON 调用通过 vue-resource 完成,表单通过 vue-form-generator 生成。

export default Vue.extend({
  template,

  data() {
    return {
      model: {
        id: 1,
        password: 'J0hnD03!x4',
        skills: ['Javascript', 'VueJS'],
        email: 'john.doe@gmail.com',
        status: true
      },

      schema: {
        fields: [
          {
            type: 'input',
            inputType: 'text',
            label: 'Website',
            model: 'name',
            maxlength: 50,
            required: true,
            placeholder: companyList
          },
        ]
      },

      formOptions: {
        validateAfterLoad: true,
        validateAfterChanged: true
      },
      companies: []
    };
  },

  created(){
    this.fetchCompanyData();
  },

  methods: {
    fetchCompanyData(){
      this.$http.get('http://echo.jsontest.com/key/value/load/dynamicly').then((response) => {
        console.log(response.data.company);
        let companyList = response.data.company; // Use …
Run Code Online (Sandbox Code Playgroud)

rest json vue.js vue-resource vuejs2

5
推荐指数
1
解决办法
2027
查看次数

使用 jQuery onChange 中的 Vue 更新数据值

我在 Vue.js 2 中使用 bootstrap-date-picker。Bootstrap datepicker 不会更新模型

但是,如果我使用以下脚本,则无法访问要使用的范围 this

loadFormProps() {
// init other stuff
$('#founding_date').change(function() {
  this.founding_date = $(this).val();
});
}
Run Code Online (Sandbox Code Playgroud)

模态如下:

data() {
  return {
    founding_date: '01 - 01 - 2017',
  }
};
Run Code Online (Sandbox Code Playgroud)

什么是最好的解决方案,因为我无法vm.$data工作,也无法this在函数内访问。

javascript jquery ecmascript-6 vuejs2

4
推荐指数
1
解决办法
3840
查看次数

标签 统计

vuejs2 ×2

ecmascript-6 ×1

javascript ×1

jquery ×1

json ×1

rest ×1

vue-resource ×1

vue.js ×1