[Vue 警告]:属性或方法"msg"不在实例上定义,但在渲染过程中引用。( "content" )...等



我的查看页面代码

<div id="app">
@{{ msg }}
@{{ content }}

在此处使用表单

<form method="post" enctype="multipart/form-data" v-on:submit.prevent="addPost">
<textarea v-model="content" id="postText" class="form-control"></textarea>
<button type="submit" id="postBtn">Post</button>
</form></div>

这是我的应用程序.js代码

const app = new Vue({
el: '#app',

在此处重新创建数据数据:{ 返回:{ 味精:"制作帖子:", 内容:", bUrl: 'http://localhost:8888/pathikhome', } }, 方法:{获取添加帖子数据

addPost(){
axios.post(this.bUrl +'/addPost', {
content: this.content
})
.then( (response) =>{
this.content="";
console.log('saved successfully'); // show if success
if(response.status===200){
app.posts = response.data;
}
})
.catch(function (error) {
console.log(error); // run if we have error
});
}
}
});

试试这段代码:

data: {
msg: 'Make Post:',
content: '',
bUrl: 'http://localhost:8888/pathikhome',
},

代替你的代码:

data: {
return:{
msg: 'Make Post:',
content: '',
bUrl: 'http://localhost:8888/pathikhome',
}
},

因为在您的代码中,您正在尝试从对象返回对象。

相关内容

最新更新