vue.js技巧小计
2024-08-30 06:12:39
//删除数组索引方法01 del (index) { this.arr.splice(index ,1); } //删除数组索引方法01 del (index) { this.$delete(this.arr, index); } //获取输入框内容 <input type="text" v-model="message" @focus="$event.target.select()">
//子向父传递参数 this.$emit('hide');<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue-demo</title> <link rel="stylesheet" href="src/dist/styles/iview.css"> <script src="src/dist/vue.min.js"></script> <script src="src/dist/iview.min.js"></script> </head> <body> <div id="page"> <my-dialog :is-show="isShow" @hide="toggle"></my-dialog> <i-button @click="toggle">显示切换</i-button> </div> <script src="src/components/text01.js"></script> </body> </html>
//js代码 //vue2.0 定义局部组件时 组件首字母要大写 vue1.0 大小写都支持 var Dialog = { template: '<div v-if="isShow">aaaaaaaaaaaaaa<i-button @click="toHide">子组件关闭</i-button></div>', props:['isShow'], methods:{ toHide:function(){ this.$emit('hide'); } } } // 注册 Vue.component('my-component', { template: '<div>A custom component!</div>' }) new Vue({ el:'#page', data:{ isShow:false }, methods:{ toggle:function(){ this.isShow = !this.isShow; } }, components: { 'my-dialog': Dialog } })
最新文章
- Util应用程序框架公共操作类(六):验证扩展
- typedef 函数指针 数组 std::function
- 利用npoi导出Excel
- BUCK-BOOST反激变压器设计
- pycharm 常用设置
- js实现简单易用的上下无缝滚动效果
- NPOI 2.0导出word(docx格式)
- Objective-C 【多个对象内存管理(野指针&;内存泄漏)】
- mac 卸载 XCode
- 【6】python核心编程 第九章-文件和输入输出
- CSS3实现时间轴效果
- reinterpret_cast,static_cast, dynamic_cast,const_cast的运用分析
- jenkins使用3----相关工具安装
- xpath分析 html文件抽正文的过程
- redhat5 安装mysql 5.6
- 【Python】torrentParser1.02
- 数据科学实战手册(R+Python)书中引用资料网址
- 【莫队】【P3834】 【模板】可持久化线段树 1(主席树)
- TangoAreaDescriptionMetaData区域描述元数据
- purfer序列题表