|
我定义了一个子组件,初始化的时候能传递参数,然后点击事件后参数不能传递过去了
<!--抽屉 v-bind:v-show="this.data.hidden"-->
<template>
<view class="my-drawer-main" v-show="displaystate">
<view class="my-drawer">
<view class="my-drawer-left" style="leftStyle" @click="leftClick">
</view>
<view class="my-drawer-right" style="rightStyle" @click="rightClick">
<text v-bind:text="text"></text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'my-drawer',
data() {
// const current = this.props.state;
// const style = "width:100%;transition:width 2s;"
// if (current) {
// }
debugger
return {
leftStyle: this.props.leftStyle,
rightStyle: this.props.rightStyle,
displaystate: this.props.displaystate,
text: this.props.msg
}
},
props: {
leftStyle: String,
rightStyle: String,
displaystate: Boolean,
msg: String
},
methods: {
installed() {//like created
console.log(this.data.displaystate);
},
updated() {
console.log(this.data.displaystate);
},
leftClick() {//点击空白处关闭抽屉
// this.data.displaystate = false;
this.fire("leftClick", "");
},
rightClick() {
console.log(this.data.displaystate);
console.log(this.data.text);
// this.data.text="测试更改"
// console.log(this.data.text);
}
}
}
</script>
<style>
.my-drawer-main {
width: 100%;
height: 100%;
/* position: absolute; */
}
.my-drawer {
height: 100%;
width: 100%;
display: flex;
flex-direction: row;
}
.my-drawer-left {
width: 20%;
background-color: #000000;
opacity: 0.5;
}
.my-drawer-right {
flex: 1;
background-color: #ffffff;
}
</style>
|
|