<template>
<div class="hello">
<ul>
<li
v-for="(item, index) in type"
@click="handle($event)"
@touchMove='touchMove'
>{{item.main}} --{{index}}</li>
</ul>
<div class="tabc">
<Tabs :text="type" :mmmmmm="msg"></Tabs> //key/value
</div>
</div>
</template> <script>
import Tabs from './tabs';
export default {
name: 'HelloWorld',
components:{
Tabs
},
data (){
return {
type:[
{main:"切换1"},
{main:"切换2"},
{main:"切换3"}
],
msg:"我是父组件的值" //要传入的值
}
},
methods:{
handle($event){
console.log($event.offsetX)
console.log($event.offsetY)
console.log($event.type)
console.log($event)
},
touchMove(ev) {
ev = ev || event;
ev.preventDefault();
// let btnWidth = this.$refs.remove.offsetWidth; //$refs 减少获取dom节点的消耗
// let btnImg = this.$refs.btnImg.offsetWidth;
console.log(ev);
// console.log(btnWidth); }
},
}
</script> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background: #ddd;
margin-bottom: 0px;
height: 40px;
line-height: 40px;
}
a {
color: #42b983;
}
</style>

  

<template>
<div class="hehe">
<h4>{{mmmmmm}}</h4>
<ul>
<li v-for="(item,index) in text">{{item.main}}</li>
</ul>
</div>
</template> <script>
export default {
name: 'hehe',
props: {
text:{ //此处为要接收的值 text为接收过来key
type:Array, //key不能乱写
default:''
},
mmmmmm:{ //同上
type:String,
default:'我是默认值'
} },
data () {
return {
hehe:"222"
}
},
methods:{ }
}
</script> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
ul,li{
list-style: none;
}
ul{
display: flex;
align-items: center;
margin-top: 5px;
} li{
flex: 1;
text-align: center;
line-height: 40px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
} h4{
text-align: center;
} </style>

  好记性不如破电脑,仅仅记录,怕忘了,不喜勿喷

vue props传值方法的更多相关文章

  1. vue props传值后watch事件未触发的问题

    父组件传值,子组件监听,明明很简单的一个事情,硬是卡了许久(毕竟不是专业搞前端的,还是吃亏在学识浅陋).也和自己钻牛角尖有关,想自己解决问题. 早期我写过一篇vue组件传值的文章,传值方式是这样的: ...

  2. Vue组件传值方法调用

    1.子组件改变父组件的值 <father  label="云盘快照" name="name2"> <son :props='rows'   @ ...

  3. Vue组件传值(一)之 父子之间如何传值

    Vue中组件之间是如何实现通信的? 1.父传子: 父传子父组件通过属性进行传值,子组件通过 props 进行接受: 1 父组件中: 2 3 <template> 4 <div id= ...

  4. 千锋教育Vue组件--vue基础的方法

    课程地址: https://ke.qq.com/course/251029#term_id=100295989 <!DOCTYPE html> <html> <head& ...

  5. iOS阶段学习第32天笔记(页面传值方法介绍)

    iOS学习(UI)知识点整理 一.界面传值方法 1.方法一  Block传值  通过SubView视图的Block向View视图传值改变View视图的背景色 实例代码: 1)SubViewContro ...

  6. atitit. js 跨界面 页面 web cs 传值方法总结

    atitit. js 跨界面 页面 web cs 传值方法总结 #--需求 js #---两个方法:   直接传跟跟间接传递... 1.直接传跟new form(param)    web使用url方 ...

  7. c#窗体的传值方法

    了解了窗体的显示相关知识,接着总结一下窗体的传值方法:  .通过构造函数  特点:传值是单向的(不可以互相传值),实现简单 实现代码如下: 在窗体Form2中         int value1;  ...

  8. vue——props的两种常用方法

    vue--props的两种常用方法 1.实现父-->子的通信 举例如下: 父组件 parent.vue <children :channel="object1"> ...

  9. vue.js之生命周期,防止闪烁,计算属性的使用,vue实例简单方法和循环重复数据

    摘要:今天是比较糟糕的一天没怎么学习,原因是学校的wifi连不上了~~.今天学习一下vue的生命周期,如何防止闪烁(也就是用户看得到花括号),计算属性的使用,vue实例简单方法,以及当有重复数据时如何 ...

随机推荐

  1. Ruby - 创建自己的GEM

    Log 1 创建自己的gem 背景:好奇gem包的用法,首先搞清楚什么是gem包.那我们就先来创建一个自己的gem包. 时间:2014-3-8 环境:Ubuntu + Ruby 1.9.3 记录:Ro ...

  2. 461. Hamming Distance(汉明距离)

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  3. 关于MYSQL编辑乱码问题

    今天在SQLyog中编写表数据时突然出现一个bug,在此记录分享一下. 使用MySQL数据库时,讲中文插入到数据苦衷进行刷新后全部都变成了乱码问号,如下图中studentName列: 产生乱码是因为没 ...

  4. 洛谷 P3959 宝藏【状压dp】

    一开始状态设计错了-- 设f[i][s]为当前与根节点联通状况为s,最深深度为i 转移的话枚举当前没有和根联通的点集,预处理出把这些点加进联通块的代价(枚举s中的点和当前点的连边乘以i即可),然后用没 ...

  5. spoj 371 Boxes【最小费用最大流】

    对于ai==0连接(i,t,1,0),对于ai>1(s,i,ai-1,0),然后对以相邻的两个点(i,j)连接(i,j,inf,1),注意这里是一个环的形式,所以1和n+1相连 #include ...

  6. SSM框架手动搭建

    SSM框架手动搭建 创建web项目 IDEA创建Maven项目 [File]-->[new]-->[project..] 将项目变为web项目 [File]-->[Project S ...

  7. [Swift]编程语言:文档修订历史

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  8. Luogu P1144 最短路计数 【最短路】 By cellur925

    题目传送门 常规的最短路计数问题:注意有重边(重边不用理,看样例),自环(读入时过滤). 另外这个无向图没有权,其实可以直接bfs做,但考虑到以后带权的情况,按spfa走了. 水题被卡了三次(嘤嘤嘤 ...

  9. Service官方教程(8)Bound Service示例之2-跨进程使用Messenger

    Compared to AIDL When you need to perform IPC, using a Messenger for your interface is simpler than ...

  10. Android 线程池系列教程(5)与UI线程通信要用Handler

    Communicating with the UI Thread 上一课 下一课 1.This lesson teaches you to Define a Handler on the UI Thr ...