
Vue
低调奋进
这个作者很懒,什么都没留下…
展开
-
vue路由守卫next is not a function
本来beforeRouteLeave(to: any, from: any, next: any)这样写的,偶尔一天,提示to,from,没有用到。就改成beforeRouteLeave(next: any)了,然后next is not a function,参数顺序问题啦原创 2021-09-02 12:12:06 · 2227 阅读 · 0 评论 -
APP.vue获取this.$route问题
在项目中偶然间遇到了这样的问题,routes注册设置的时候使用了懒加载的方式,如下:routes: [ { path: '/', name: 'index', // component: index //方式1 component: () => import('./views/index.vue'); //方式2 }, ...]如果是这种方式(方式2),那么在app.vue中你如果先要在 created 或者翻译 2021-09-02 12:10:05 · 3508 阅读 · 0 评论 -
:last-child 无效
使用 :last-child 伪类时要保证后面没有兄弟元素节点!!!!!!!原创 2021-08-26 10:51:54 · 379 阅读 · 0 评论 -
原生复制方法
function copyData(data){ const input = document.createElement('input'); document.body.appendChild(input); input.setAttribute('value', data); input.select(); if (document.execCommand('copy')) { document.execCommand('copy'); alert('复制成功');.原创 2021-08-03 17:46:30 · 2222 阅读 · 0 评论 -
VUE中通过改变key去更新局部dom
在使用Elemen-UI中el-select时代码如下↓ 1 2 3 4 5 6 7 8 9 10 11 12 13 <!-- selected --> <el-select v-if="item.columnType === 'selected'" :key="updates" v-model="sco...转载 2021-07-30 17:42:53 · 2600 阅读 · 0 评论 -
表单验证问题
rules中,input失焦时校验,2种写法不能同时使用:1.trigger: 'blur'2.private onBlurEmail() {this.formRef.validateFields('email');}原创 2021-07-30 17:35:01 · 187 阅读 · 0 评论 -
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c
@Prop({ type: Array, default: [] }) private readonly allSelected?: Array<string> = [];上面写法有问题!!!!!1.allSelected不能修改2.allSelected不能初始化!原创 2021-07-20 17:44:36 · 202 阅读 · 0 评论 -
ModHeader插件解决跨越问题
待更原创 2021-06-28 12:06:51 · 1168 阅读 · 0 评论 -
使用vue组件遇到的坑
版本1:value="1">Self-Relatedvalue="2">ALLdataList.Else的值是字符串!版本2:value="1">Self-Relatedvalue="2">ALLdataList.Else的值是number!boolean类型同理,:value="true"(boolean) value="true"(string)...原创 2021-06-27 10:42:12 · 2209 阅读 · 0 评论 -
Vue在ts中的使用beforeRouteLeave
路由守卫,发现不生效。beforeRouteLeave(to: any, from: any, next: any) {alert(111)next();}原因:看起来简洁明了,但是直接拿到项目中去,会发现没有触发,ps(项目用ts);还需要在该组件加行代码:import { Component } from 'vue-property-decorator';Component.registerHooks(['beforeRouteEnter', 'beforeRoute原创 2021-06-26 23:50:07 · 1172 阅读 · 2 评论 -
vue 报错Avoid mutating a prop directly since the value will be overwritten whenever the parent compone
产生错误的原因:在子组件中,你试图修改父组件通过props与子组件通信的数据。两种解决方法:将这个父组件传进来的要修改的数据,通过$emit再传回给父组件,在父组件中进行修改。当父组件通过props与子组件通信时,可以将数据放在一个对象中传递给子组件,这时再子组件就可以修改对象中的属性,也就修改了父组件传过来的数据。...原创 2021-06-23 10:03:34 · 651 阅读 · 0 评论 -
vue递归组件传值和传递事件
$emit无法实现,用eventBus方式。原创 2021-06-22 20:18:51 · 927 阅读 · 0 评论 -
初始Vue笔记之——Class 与 Style 绑定
绑定 HTML Class对象语法<div v-bind:class="{ active: isActive }"></div>数组语法<div v-bind:class="[activeClass, errorClass]"></div>在数组语法中也可以使用对象语法:<div v-bind:class="[{ ...翻译 2019-07-01 11:26:45 · 171 阅读 · 0 评论 -
初始Vue笔记之——表单输入绑定
v-model会忽略所有表单元素的value、checked、selected特性的初始值而总是将 Vue 实例的数据作为数据来源。应该通过 JavaScript 在组件的data选项中声明初始值。对于需要使用输入法(如中文、日文、韩文等) 的语言,你会发现v-model不会在输入法组合文字过程中得到更新。如果你也想处理这个过程,请使用input事件。组件基础组件的...翻译 2019-07-05 13:42:34 · 296 阅读 · 0 评论 -
初始Vue笔记之——计算属性和侦听器
计算属性var vm = new Vue({ el: '#example', data: { message: 'Hello' }, computed: { // 计算属性的 getter reversedMessage: function () { // `this` 指向 vm 实例 return this.message....翻译 2019-06-28 11:51:57 · 168 阅读 · 0 评论 -
初始Vue笔记之——模板语法
插值通过使用v-once 指令,你也能执行一次性地插值,当数据改变时,插值处的内容不会更新。但请留心这会影响到该节点上的其它数据绑定:<span v-once>这个将不会改变: {{ msg }}</span>双大括号会将数据解释为普通文本,而非 HTML 代码。为了输出真正的 HTML,你需要使用v-html指令:<p>Using must...翻译 2019-06-28 11:27:25 · 250 阅读 · 0 评论 -
初始Vue笔记之——Vue 实例
数据与方法实例生命周期钩子不要在选项属性或回调上使用箭头函数,比如created: () => console.log(this.a)或vm.$watch('a', newValue => this.myMethod())。因为箭头函数并没有this,this会作为变量一直向上级词法作用域查找,直至找到为止,经常导致Uncaught TypeError: Cann...翻译 2019-06-28 11:03:39 · 191 阅读 · 0 评论