【问题标题】:3 errors on function from vue js来自 vue js 的 3 个函数错误
【发布时间】:2020-12-18 10:32:48
【问题描述】:

我的错误:

  1. app.js:44406 [Vue 警告]:属性或方法“__”未在实例上定义,但在渲染期间被引用。通过初始化该属性,确保此属性是反应性的,无论是在数据选项中,还是对于基于类的组件。请参阅:https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties。 在 ---> 在 resources/js/components/ChatComponent.vue 中找到

  2. app.js:44406 [Vue 警告]:渲染错误:“TypeError: vm._ is not a function” ---> 在资源/js/components/ChatComponent.vue

  3. 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


    【解决方案1】:

    您正在混合前端和后端功能。 __ 函数是用于文本本地化的 laravel 特定助手。但是你不能在 Vue JavaScript 中使用 laravel php 函数。因此,您会收到找不到函数等错误。

    您需要为您的前端单独配置本地化。看看:https://kazupon.github.io/vue-i18n/

    【讨论】:

    • 谢谢我完全忘了拿出提交按钮
    猜你喜欢
    • 2021-11-23
    • 2021-03-15
    • 2018-12-28
    • 1970-01-01
    • 2021-11-15
    • 2016-06-28
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多