您的位置:首页 > 健康 > 养生 > 长春人才招聘网官网_抖音小程序推广怎么挂才有收益_软文范例大全300字_目前最火的推广平台

长春人才招聘网官网_抖音小程序推广怎么挂才有收益_软文范例大全300字_目前最火的推广平台

2024/10/5 4:35:58 来源:https://blog.csdn.net/m0_37570176/article/details/142642616  浏览:    关键词:长春人才招聘网官网_抖音小程序推广怎么挂才有收益_软文范例大全300字_目前最火的推广平台
长春人才招聘网官网_抖音小程序推广怎么挂才有收益_软文范例大全300字_目前最火的推广平台

组件源码

<template><view class="c_container" :style="myStyle" @click="clickCust"><view style="font-size: 18px;text-align: center;">{{item.name}}</view><view style="margin-top: 10px;font-size: 10px;"><view style="text-align: center;">{{item.sex+"&nbsp;&nbsp;&nbsp;"+item.age+"岁"}}</view></view></view></template><script>export default {name: "Customer",props: {item: {type: Object,default: {id: 0,name: "王美丽",sex: '女',age: 24}},selected: {type: Boolean,default: false}},watch: {selected(val) {console.log("watch,selected", this.selected);this.isSelected = this.selected;}},data() {return {isSelected: false,selectedColor: '#ffffff',unselectedColor: '#f4f4f4',borderColor: '#1296db',myStyle: ''};},mounted() {this.setStyle();},methods: {setStyle() {if (this.isSelected) {//选中this.myStyle = {"background-color": this.selectedColor,border: "1px solid " + this.borderColor};} else {//没选中this.myStyle = {"background-color": this.unselectedColor,border: "none"};}console.log("this.myStyle", this.myStyle);},clickCust() {this.isSelected = !this.isSelected;console.log("clickCust,isSelected", this.isSelected);this.setStyle();this.$emit("clickCust", {id: this.item.id,isSelected: this.isSelected});}}}
</script><style>.c_container {/* float: left; */height: 60px;width: 150px;border: 1px solid;padding-top: 20px;border-radius: 15px;margin-right: 10px;}
</style>

调用组件

<template><view class="s_container"><uni-nav-bar :fixed="true" dark background-color="#007AFF" title="预约咨询" class="nav" left-icon="left"@clickLeft="back" /><view class="c_box"><view><image mode="widthFix" style="width: 100%"src="/static/images/myimages/fetal_counseling/fetal_counseling_1.jpg"></image></view><view class="box2"><view class="box2_title_box"><view class="box2_title">选择服务客户</view><view class="box2_right" @click="addCustomer">+添加</view></view><scroll-view :scroll-x="true" style="width: 100%;padding: 10px 0;"><view style="width: 2000px;"><!-- <view class="card" v-for="item in customers"style="float:left;height: 60px;width: 150px;border: 1px solid ;padding-top: 20px;border-radius: 15px;margin-right: 10px;"><view style="font-size: 18px;text-align: center;">{{item.name}}</view><view style="margin-top: 10px;font-size: 10px;"><view style="text-align: center;">{{item.sex+"&nbsp;&nbsp;&nbsp;"+item.age+"岁"}}</view></view></view> --><Customer ref="cust" v-for="item in customers" :item="item" style="float: left;"@clickCust="clickCustomer"></Customer></view></scroll-view><view style="clear: both;"></view><view><button @click="test">测试</button></view></view></view></view>
</template><script>import Customer from "@/components/Customer.vue"export default {components: {Customer},data() {return {customers: [{id: 1,name: '王美丽',sex: '女',age: '24'}, {id: 2,name: '王美丽1',sex: '女',age: '24'}, {id: 3,name: '王美丽2',sex: '女',age: '24'}, {id: 3,name: '王美丽3',sex: '女',age: '24'}, {id: 4,name: '王美丽4',sex: '女',age: '24'}]}},methods: {back() {uni.showToast({title: '回退'})},addCustomer() {uni.showToast({title: '添加客户'})},clickCustomer(e) {console.log("clickCustomer,e", e);},test() {console.log("cust", this.$refs.cust);//调用数据console.log("cust[0]", this.$refs.cust[0].isSelected);//调用方法this.$refs.cust[0].clickCust();}}}
</script><style>.s_container {background-color: rgba(244, 244, 244, 1);}.c_box {padding: 8px 8px;}.box2 {padding: 5px;margin-top: 5px;background-color: #ffffff;}.box2_title_box {position: relative;}.box2_title {font-size: 14px;font-weight: bold;}.box2_right {position: absolute;right: 20px;top: 0px;}
</style>

调用组件数据和方法的代码

test() {console.log("cust", this.$refs.cust);//调用数据console.log("cust[0]", this.$refs.cust[0].isSelected);//调用方法this.$refs.cust[0].clickCust();
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com