vue中指令写了一个demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>指令</title>
<link rel="stylesheet" href="vlib/css/index.css">
<style>
*{margin:;padding:;box-sizing:border-box;}
a{text-decoration:none;}
</style>
</head>
<body>
<script src="vlib/vue.js"></script>
<script src="vlib/index.js"></script>
<div id="app">
<component-child v-if="list" :mess="list"></component-child>
<div>
<button @click="myupdate">更新</button>
<button @click="mydel">卸载</button>
<button @click="myinstall">安装</button>
</div>
</div>
<script>
Vue.directive('limitStr',{
bind:function(el,binding,vcode){
console.log();
},
inserted:function(el,binding,vcode){
console.log();
},
update:function(el,binding,vcode){
console.log();
},
componentUpdated:function(el,binding,vcode){
console.log();
},
unbind:function(el,binding,vcode){
console.log();
}
})
var componentChild = {
template:'<div>\
{{messval}}\
<input type="text" :value="mess" v-limit-str>\
</div>',
data: function(){
return {
messval:this.mess
}
},
props:{
mess:{
type:String,
default:''
}
},
methods:{
getVal:function(e){
this.messval = e.target.value
}
}
}
new Vue({
el:'#app',
data:{
list:'hello word!!!'
},
components:{
componentChild:componentChild
},
methods:{
myupdate:function(){//更新
this.list = '更新了!!123'
},
mydel:function(){//卸载
this.list = '';
},
myinstall:function(){//安装
this.list = 'china!!!';
}
}
})
</script>
</body>
</html>
vue中指令写了一个demo的更多相关文章
- 在VS中实现webService的一个demo(图解)
在VS中实现webService的一个demo(图解) 先创建一个web项目,创建好web项目后,添加新建项——web服务 在新建好的web服务文件中写如下代码: 生成当前解决方案. 新建一个winf ...
- NDK中使用pthread多线程中自己写的一个BUG
在使用pthread进行NDK中的多线程开发时,自己写了一个BUG, void *darkGrayThread(void *args) { ThreadParam *param = (ThreadPa ...
- vue中data必须是一个函数
前端面试时经常被问到:“组建中data为什么是函数”? 答案就是:在组件中data必须是一个函数,这样的话,每个实例可以维护一份被返回对象的独立拷贝.
- vue中,写在methods里的B方法去调A方法的数据,访问不到?
今天在写项目的时候,发现了一个京城性忽略的问题,在vue的methods的方法里面定义了两个方法,如下: getTaskList() { api.growthDetails.taskList({ ap ...
- opencv debug版本在linux下编译,并写了一个DEMO
用如下方法编译opencv: git clone "https://github.com/opencv/opencv.git" mkdir opencv_debug cd open ...
- vue中指令绑定的v-if逻辑结构
<!-- if判断 --> <div id="app2"> <p v-if="seen"> <!-- 给p标签绑定指令 ...
- vue中路由返回上一个页面,恢复到上一个页面的滚动位置
第一步:路由文件的配置(对你所需要的vue文件进行保存缓存标志的添加) import Vue from 'vue' import Router from 'vue-router' import Hel ...
- vue中使用router打开一个新的窗口
一个单页应用打开一个新的窗口不是很好控制,比如权限的处理,因为原先的页面不会自动刷新,方法很简单: let routeData = this.$router.resolve({ name: " ...
- 3-6 Vue中的条件渲染
本次案例讲解:v-if,v-show,v-else,v-else-if和key值的相关用法!!! v-if指令: //通过一个(v-if)指令 ,可以结合js表达式的返回值,决定一个标签是否在页面上展 ...
随机推荐
- UI组件之TextView及其子类(一)TextView和EditText
先来整理一下TexView,EditView的使用方法. Textview是最主要的组件.直接继承了View,也是众多组件的父类.所以了解她的属性会对学习其它组件非常有帮助. TextView的属性: ...
- web security
brute force cracking 暴力破解 Brute force (also known as brute force cracking) is a trial and error me ...
- C# 应用异常捕获
program.cs static class Program { /// <summary> /// The main entry point for the application. ...
- php获取js里的参数
php获取js的值有如下方式: 1.php echo出js文件得到返回值,在gamemap.js文件中输出参数. echo '<script type="text/javascript ...
- 玩转HTML5移动页面(优化篇)
标签:h5 页面优化收藏 热门分享 网页设计师必备的 酷站收藏网站 2013年不容错过的app ui素材 40个漂亮的扁平化网页设计欣赏 国内网页设计公司网站欣赏 55套网页设计常用的psd格式UI ...
- [SCOI2009]windy数 数位dp
Code: #include<cmath> #include<iostream> #include<cstdio> using namespace std; con ...
- SP1487 PT07J - Query on a tree III 主席树+dfs序
Code: #include<iostream> #include<cstdio> #include<algorithm> #include<string&g ...
- Vue this.$router.push、replace、go的区别
1.this.$router.push 描述:跳转到不同的url,但这个方法会向history添加一个记录,点击后会返回到上一个页面 用法 //字符串 this.$router.push('home' ...
- NOIp2018模拟赛三十五
两道大数据结构把我砸懵 成绩:未提交 Orz xfz两道正解 A:[BZOJ4049][CREC2014B]mountainous landscape B:CJB的大作(CF改编题)
- CSS核心原理
1.优先原则: 后解析的内容,会覆盖掉之前解析的内容: 同一个选择器:文件执行从上往下,后面的样式会覆盖前面的: 如下例中color最终为粉色: div { color:red; color:pink ...