使用vux组件库常见报错($t)处理
错误一:
[Vue warn]: Property or method "$t" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
解决方案:
如果没有安装vuex和vuex-i18n需要先安装,然后在main.js中引入以下代码。在new Vue的时候,把store写上
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app-box')
import Vuex from 'vuex';
import vuexI18n from 'vuex-i18n';
Vue.use(Vuex);
const store = new Vuex.Store({
modules: {
i18n: vuexI18n.store
}
});
Vue.use(vuexI18n.plugin, store);
const translationsEn = {
"content": "This is some {type} content"
}; Vue.i18n.add('en', translationsEn);
Vue.i18n.set('en');
或者直接把$t删除,直接用相应的汉语或者英语。
$t是一个翻译函数,如果你的项目不需要国际化,切换语言,那么你就可以把$t删除。
错误二:
Uncaught TypeError: Cannot read property 'alert' of undefined at eval
解决方案:
import { AlertPlugin, DatetimePlugin, ConfirmPlugin, LoadingPlugin, ToastPlugin } from 'vux'
Vue.use(AlertPlugin)
Vue.use(DatetimePlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
Vue.use(ToastPlugin)
在main.js中加入以上代码,没有用到的插件可以不引入。以上几个是我总结出来的容易报错的几个插件。错误原因是你的代码中使用了 this.$vux.alert等类似代码,而$vux是在插件中向vue中添加的,所以得引入相应的插件。
使用vux组件库常见报错($t)处理的更多相关文章
- 记:使用vue全家桶 + vux组件库 打包成 dcloud 5+ app 开发过程中遇到的问题
vue-cli 版本:2.9.6 webpack 版本:3.6.0 1. vue-cli 安装好之后,不是自动打开默认浏览器 在 config文件夹 ---> dev选项中,有个 autoO ...
- Nginx 常见报错
Nginx 常见报错 启动报错:[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 原因:这个是nginx重启时经常遇到 ...
- 内置Jetty配置JSP支持过程中的常见报错
目录 1. 常见报错及解决 1.1 JSP support not configured 1.2 JSTL标签解析 1.3 JSP编译 1.4 JSP实现依赖 1.5 EL表达式支持 2. 小结 1. ...
- rsync 守护进程模式搭建 与常见报错
守护进程模式搭建 1.环境准备 2.安装rsync(做备份的服务器都安装) [root@backup ~]# yum install -y rsync 3.服务端配置 [root@backup ~]# ...
- bootsrap+jquery+组件项目引入文件的常见报错
做一个项目的时候 ,控制台总是会出现各种bug,其实不用慌张,终结起来也就几种类型的错误,在开发中每次遇到错误都善于总结,下次在看到就会胸有成竹知道是什么情况了,以下是在开发过程中总结的一些错误以及错 ...
- WAS 常见报错
1) An error occurred while deleting the server. ADMG0011E: An unexpected exception occurred com.ibm. ...
- Android Studio编译开源项目(含NDK开发)常见报错
1.未设置NDK的路径 Error:Execution failed for task ':library:ndkBuild'. > A problem occurred starting pr ...
- datatables常见报错
Uncaught TypeError: Cannot read property 'style' of undefined 分析:列表配置 columnDefs 列数不匹配 来自为知笔记(Wiz)
- ReactNative常见报错
1.导出模块错误 遇到这样的错误,首先检查代码有闭合一致,如果没有错误的话,则去检查是否是导出模块的错误. 如: export default moduleName; 改为: module.expor ...
随机推荐
- mysql查询某个字段并修改
比如我存储的数据,有的是 山东,有的是山东省 我想统一改为山东省 UPDATE t_security SET province = REPLACE( province, '山东', '山东省' ) W ...
- Java基础-注解
什么是注解? Jdk1.5新增新技术,注解.很多框架为了简化代码,都会提供有些注解.可以理解为插件,是代码级别的插件,在类的方法上写:@XXX,就是在代码上插入了一个插件. 注解不会也不能影响代码的实 ...
- Spring Boot Redis 集成配置(转)
Spring Boot Redis 集成配置 .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px #ede ...
- 【logo】设计书籍的logo
一个女孩发光般的看着,眼前发现的书籍 含义:这本书就是女孩想要得到的书籍 平台的宗旨:就是让学生能够得到想要的书籍 书籍来源:其他学生的书籍 目的:实现书籍回收再利用,同时让接受者低于市场价得到
- leetcode 60-80 easy
66.Plus One Given a non-empty array of digits representing a non-negative integer, plus one to the i ...
- python实现贝叶斯网络的概率推导(Probabilistic Inference)
写在前面 这是HIT2019人工智能实验三,由于时间紧张,代码没有进行任何优化,实验算法仅供参考. 实验要求 实现贝叶斯网络的概率推导(Probabilistic Inference) 具体实验指导书 ...
- AOP Aspect 统一日志、异常处理、数据格式 【转】
package com.gsww.chis.aop; import java.util.Arrays; import com.google.common.base.Throwables; import ...
- 【django后端分离】Django Rest Framework之一般配置(简单剖析)
1:常设状态码 200 OK - [GET]:服务器成功返回用户请求的数据,该操作是幂等的(Idempotent). 201 CREATED - [POST/PUT/PATCH]:用户新建或修改数据成 ...
- Lambada. 计算和
Lambada. 计算和 import java.util.Arrays; import java.util.List; public class ListLambada { public stati ...
- Leetcode905.Sort Array By Parity按奇偶排序数组
给定一个非负整数数组 A,返回一个由 A 的所有偶数元素组成的数组,后面跟 A 的所有奇数元素. 你可以返回满足此条件的任何数组作为答案. 示例: 输入:[3,1,2,4] 输出:[2,4,3,1] ...