【问题标题】:TypeError: "_vm.KisanData is undefined" in Vue.js类型错误:Vue.js 中的“_vm.KisanData 未定义”
【发布时间】:2020-04-02 09:27:06
【问题描述】:

我无法修复错误,请帮忙。

这是使用 KisanData 但发生错误的方法我无法解决此问题

const API_URL = "http://localhost:3000/User";
    export default {
      name: "home",
      info(){
        return{
        info: [],
        KisanData: {
          name: "",
          village: ""
        },
        }
      },

这是我使用 v-model 但出现错误的 html 代码

<span class="input10" for="name">Name</span>
                  <input
                    id="name"
                    class="input1"
                    type="text"
                    v-model="KisanData.name"
                    name="name"
                    placeholder="Enter your name" required
                  />
                  <span class="focus-input100"></span>
                </div>
                <div class="input100" data-validate="Name is required">
                  <span class="input10" for="village">Village</span>
                  <input
                    class="input1"
                    id="village"
                    type="text"
                    v-model="KisanData.village"
                    name="village"
                    placeholder="Enter your Village name" required
                  />
error occur on console

【问题讨论】:

  • 请不要注意括号

标签: javascript vue.js


【解决方案1】:

您应该使用字段data 而不是info:


const API_URL = "http://localhost:3000/User";
export default {

    name: "home",

       data() {
            return {
                info: [],
                KisanData: {
                   name: "",
                   village: ""
                },
            }
        }
},

【讨论】:

  • 我更改但出现新错误“属性或方法“name1”未在实例上定义,但在渲染期间被引用”
  • 伙计,我在您的代码中没有看到任何属性或方法“name1”。您能否将我的答案标记为正确答案以给我一些意见?我帮你解决了当前的问题。
猜你喜欢
  • 2020-05-06
  • 2018-04-03
  • 2019-10-31
  • 1970-01-01
  • 2020-07-02
  • 2016-08-07
  • 2019-01-07
  • 2020-01-28
  • 2021-10-24
相关资源
最近更新 更多