Vue 2.0 明明页面模板里面已经读取到了数据,为啥还会报错TypeError: Cannot read properties of null
网页
<h1 class="no-margins" id="vue-content" >
{{salesdataUTD.total_visit}}
</h1>
Vue
<script type="text/javascript">
Vue.config.productionTip = false //组织生产提示
// 获取账号
var phoneNumber = document.getElementById("mydata-userphone").innerHTML
// 创建VUE实例
new Vue({
el:"#vue-content",//
data : {
salesdataUTD: null,
},
mounted:function (){
axios
.get('http://127.0.0.1:8000/bigdata/get_up_to_data_salesdata',{
params:{
phone:phoneNumber
}
})
.then((response) =>{
this.salesdataUTD=response.data.salesdataUTD
})
.catch(function (error) { // 请求失败处理
console.log(error);
});
}
})
</script>
在开发者工具里面也能看数据
并且在页面上也能显示数据
,但就是在后台报错
刚开始学VUE. 不知道怎么解决,
这个报错影响我后续JS的运行了