【发布时间】:2020-12-18 10:32:48
【问题描述】:
我的错误:
-
app.js:44406 [Vue 警告]:属性或方法“__”未在实例上定义,但在渲染期间被引用。通过初始化该属性,确保此属性是反应性的,无论是在数据选项中,还是对于基于类的组件。请参阅:https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties。 在 --->
在 resources/js/components/ChatComponent.vue 中找到 -
app.js:44406 [Vue 警告]:渲染错误:“TypeError: vm._ is not a function” --->
在资源/js/components/ChatComponent.vue -
TypeError: vm._ 不是函数。
<template>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="card">
<div class="card-body minh overflow-auto"></div>
</div>
<div class="mt-3">
<div class="form-group">
<div class="input-group mb-3">
<input
type="text"
class="form-control"
v-bind:placeholder="placeholder"
aria-label="Recipient's username"
aria-describedby="button-addon2"
v-model="messageField"
/>
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="button-addon2">{{__('auth.submit')}}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
let messages = {};
export default {
data() {
return{
messages: {},
messageField: ""
}
},
props:[
'placeholder'
],
mounted() {
this.getMessagess();
},
methods: {
getMessagess() {
axios
.get("/messagefetch")
.then(response => {
this.messages = response.data;
})
.catch(function(error) {
console.log(error);
});
},
postMessage() {
axios
.post("/api/messagesend", {
api_token: this.user.api_token,
message: this.messageField
})
.then(response => {
this.message.push(response.data);
this.messageField = "";
})
.catch(function(error) {
console.log(error);
});
}
}
};
</script>
我从数据库中获取消息,并且我的道具占位符也很好,但我没有在前端看到我的组件。此外,vue.js 本身生成的函数出现 3 个错误,这些函数被编译并放入 app.js。我是 vue.js 的新手,所以我不确定我做错了什么
【问题讨论】:
标签: laravel vue.js frontend vue-component