vue子组件使用指令 同时绑定v-model 指令没有作用
//这里直接上代码
<!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 :mess="'测试数据123'"></component-child>
</div>
<script>
Vue.directive('limitStr',function(el,bind,vcode){
var changeInput = function(){
var name = bind.value && bind.value.name;
var len = bind.value && bind.value.len;
if(el.value.trim().length > len){
el.value = el.value.slice(,len);
}
}
el.addEventListener('input',changeInput)
})
var componentChild = {
template:'<div>{{messval}}<input type="text" :value="messval" @input="getVal" v-limit-str="{len:10}"></div>',
data: function(){
return {
messval:this.mess
}
},
props:{
mess:{
type:String,
default:'abc'
}
},
methods:{
getVal:function(e){
this.messval = e.target.value
}
},
watch:{
messval:function(){
){
,);
}
}
}
}
new Vue({
el:'#app',
components:{
componentChild:componentChild
}
})
</script>
</body>
</html>
vue子组件使用指令 同时绑定v-model 指令没有作用的更多相关文章
- Vue 子组件向父组件传参
直接上代码 <body> <div id="counter-event-example"> <p>{{ total }}</p> & ...
- Vue子组件调用父组件的方法
Vue子组件调用父组件的方法 Vue中子组件调用父组件的方法,这里有三种方法提供参考 第一种方法是直接在子组件中通过this.$parent.event来调用父组件的方法 父组件 <temp ...
- Vue 子组件调用父组件 $emit
<!DOCTYPE html><html> <head> <meta charset="utf-8"> ...
- vue子组件通知父组件使用方法
vue子组件通知父组件使用方法 <template> <mt-field placeholder="验证码" v-model="getverifycod ...
- Vue子组件传递数据给父组件
子组件通过this.$emit(event,data)传递数据到父组件 以下是例子: father.vue 父组件 <template> <div> <child @ne ...
- Vue子组件与父组件之间的通信
1.环境搭建 下载 vue-cli:npm install -g vue-cli 初始化项目:vue init webpack vue-demo 进入vue-demo文件夹:cd vue-demo 下 ...
- vue 子组件调用父组件的方法
vue中 父子组件的通信: 子组件通过 props: { //子组件中写的. childMsg: { //字段名 type: Array,//类型 default: [0,0,0] //这样可以指定默 ...
- vue 子组件和父组件
作者QQ:1095737364 QQ群:123300273 欢迎加入! 1.添加子组件 1.父组件修改 <template> <!-- v-for 表情表示循环输出数据 ...
- vue 子组件把数据传递给父组件
<div id="app"> <child v-on:drop='parent'></child> //这里v-on:drop="pa ...
- vue子组件如何向父组件传值
子组件: <template> <div class="app"> <input @click="sendMsg" type=&q ...
随机推荐
- 软工视频总结Part Three
软件需求分析 任务 解决目标系统"做什么"问题 深入描写叙述软件的功能和性能 确定软件涉及到的约束和软件接口 定义软件的其它有效需求 特点 一致性.完整性.限时性.有效性.可验证性 ...
- QMutex“A mutex must be unlocked in the same thread that locked it”解决(在run里创建对象是不二法宝)
多线程时出现如下警告信息: A mutex must be unlocked in the same thread that locked it: 原因可能有二: 1.创建QMutex不在当前线程: ...
- Linux下处理JSON的命令行工具:jq---安装
转自:https://blog.csdn.net/Sunny_much/article/details/50668871 JSON是前端编程经常用到的格式.Linux下也有处理处理JSON的 ...
- C# 分隔字符串成为字符串数组的方法(保留分隔符)
要求如下: source string: mmmmmmynameismickeym separator: m result string []: {"m", "m&quo ...
- hiho1079 - 数据结构 线段树(入门题,离散化)
题目链接 描述 小Hi和小Ho在回国之后,重新过起了朝7晚5的学生生活,当然了,他们还是在一直学习着各种算法~ 这天小Hi和小Ho所在的学校举办社团文化节,各大社团都在宣传栏上贴起了海报,但是贴来贴去 ...
- springmvc两种非注解的处理器适配器
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...
- HDU 2120 Ice_cream's world I【并查集】
解题思路:给出n对点的关系,求构成多少个环,如果对于点x和点y,它们本身就有一堵墙,即为它们本身就相连,如果find(x)=find(y),说明它们的根节点相同,它们之间肯定有直接或间接的相连,即形成 ...
- No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'
控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...
- C# AES 加解密处理
引言 这是一个有关AES加解密的方法类 一.设置AES加解密密钥:下面列出自己分配的三类密钥 private const string UserKey = "roshan-2015-user ...
- Vue 中 换行符获取
当要获取到 vue 中 文本域的换行符时, 需要用到正则匹配. let reg = new RegExp('/n',"g"); let str = text.replace(reg ...
