标签:str upload 缓存 rda fat param router ssi event
let params = {
amount :item.amount, //金额
payment :item.payment, //交易方式
code :item.code, //商家代码
serial_num :item.serial_num, //流水号
}
this.$router.push({path:‘/income/detail‘,name:‘incomeDetail‘,params:params})
let params = this.$route.params
const orderData = {‘orderId‘:123456,‘price‘:100}
sessionStorage.setItem(‘缓存名称‘,JSON.stringify(orderData))
const data = JSON.parse(sessionStorage.getItem(‘缓存名称‘))
原理:父组件通过props向下传递数据给子组件,子组件通过events给父组件发送消息。
props
父组件App.vue
<template>
<div id="app">
<child :childMessage="content"></child>
</div>
</template>
<script>
import child from ‘./components/Child‘
export default {
name : ‘app‘
components:{
child
}
data(){
return {
content:‘Send Message to Child‘
}
}
</script>
子组件Child.vue
<template>
<div>
<h2>child子组件部分</h2>
<p>{{childMessage}}</p>
</div>
</template>
<script>
export default {
//方式1
props: [‘childMessage‘]
//方式2
props: {
childMessage: String //指定类型
}
//方式3
props : {
childMessage:{
type:String, //指定类型,常用类型有 String Number Object Boolean...
default:‘‘
},
}
}
</script>
父组件App.vue
<template>
<child @showMessage="show" :message="message"></child> //监听子组件触发的showMessage事件,然后调用show方法
</template>
<script>
methods: {
show(message) {
this.message = message;
}
}
</script>
子组件Child.vue
<template>
<div @click="sendMessage"></div>
</template>
<script>
methods: {
sendMessage() {
this.$emit(‘showMessage‘,‘Send Message to Father‘); //触发showbox方法,‘the msg‘为向父组件传递的数据
}
}
</script>
标签:str upload 缓存 rda fat param router ssi event
原文地址:https://www.cnblogs.com/littleBit/p/8995009.html