随笔分类 - vue
vue相关
摘要:1.确定字典获取的接口 目录在 /src/api/index.js // 根据字典类型查询字典数据信息 export function getDicts(dictType) { return new Promise((resolve)=>{ resolve({ code: 200, data: [{
阅读全文
摘要:Vue中 v-model 和 :model 的区别 1、v-model 通常用于表单上双向数据的绑定,如果除了表单其他组件使用时,起不到任何效果。 它还可以实现子组件到父组件的双向数据动态绑定。 input上的v-model: <input v-model="price"><!-- 下行注释的语法糖
阅读全文
摘要:element中select组件加入滚动分页及模糊查询 1.directive.js-自定义vue指令 import Vue from 'vue' export default () => { Vue.directive('loadMore', { bind (el, binding) { // 如
阅读全文
摘要:vue中attrs的使用 1.attrs的作用 用来进行子孙组件之间的数据传递 接收父组件传过来,但是又没有在props中定义的数据。(class及style除外) 2.父子组件之间数据传递的用法 爷爷组件-grandpa: <template> <div> <span>爷爷</span> <Son
阅读全文
摘要:作用: 组件切换时保持组件状态不被销毁 属性: include——包括:值为字符串或正则表达式或数组;指定的组件被缓存 exclude——不包括:值为字符串或正则表达式或数组;指定的组件不被缓存 exclude优先级高于include 用法: <keep-alive include="home,ab
阅读全文
摘要:egg:父组件监听子组件挂载并做对应的逻辑处理 1.在子组件中通过this.$emit触发父组件的事件 // Parent.vue <Child @mounted="doSomething"/> doSomething() { console.log('doSomething'); } // Chi
阅读全文
摘要:作用:用于子组件中触发父组件方法并传值 使用一:$emit //子组件中 <template> <button @click="handleChildEvent">子组件中触发的事件</button> </template> <script> export default { name:'Child
阅读全文
摘要:适用场景: 如果要改变data中的对象或者数组,会发现data数据改变了,但是页面上并没有更新 如: this.list[index].sex = '男'; 此时要想更新可以使用 this.$set(this.list[index],'sex','男') 也可以使用 this.list[index]
阅读全文