Javascript Vue js。数据字段不绑定

Javascript Vue js。数据字段不绑定,javascript,html,vue.js,vuejs2,two-way-binding,Javascript,Html,Vue.js,Vuejs2,Two Way Binding,我对Vue元素有以下定义: newvue({ el:“应用程序”, 数据:{ 纬度1:‘a’, 名称:“aa” }, 安装的(){ if(导航器.地理位置){ navigator.geolocation.getCurrentPosition(位置=>{ this.latitude1=position.coords.lation; }) }否则{ this.latitude1=“WTF??” //这也不起作用: //此.$nextTick(()=>{this.latitude1=“WTF???”

我对Vue元素有以下定义:

newvue({
el:“应用程序”,
数据:{
纬度1:‘a’,
名称:“aa”
},
安装的(){
if(导航器.地理位置){
navigator.geolocation.getCurrentPosition(位置=>{
this.latitude1=position.coords.lation;
})
}否则{
this.latitude1=“WTF??”
//这也不起作用:
//此.$nextTick(()=>{this.latitude1=“WTF???”})
}
},
方法:{
//按钮工作…WTF?!?
doIt(){
this.latitude1=“WTF??”
}
}
});

{{latitude1}}:{{name}
做吧

在Vue.js中要做的一件事是使用定义的方法进行被动属性更改

以下是我为其提供的代码:

function error(err) {
  console.warn(`ERROR(${err.code}): ${err.message}`);
}

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

new Vue({
  el: "#app",
  data: {
    latitude1: 'a',
    name: 'aa'
  },
  mounted: function() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(position => {
        console.log(position.coords.latitude);
        Vue.set(this, 'latitude1', position.coords.latitude);
      }, error, options)
    }
  }
});
我还为navigator查询设置了错误处理程序和选项。有关以下结果,请检查控制台