• uni-app 组件小demo


    留存一下,省的忘了。

        <!-- 子组件通过 $emit 控制父组件的事件 -->
        <!-- 父组件通过属性,给子组件传值 -->
    

      

    父组件引用

    <template>
    	<view>
    		<shuru :huizi="'姓名'" v-model="data" @input="cc" @click="zudianji"></shuru>
    		<view @click="houqu">获取一下看看</view>
    	</view>
    </template>
    
    <script>
    import shuru from '../../components/text_ipt/text_ipt.vue';
    export default {
    	components: {
    		shuru
    	},
    	data() {
    		return {
    			data: ''
    		};
    	},
    	methods: {
    		houqu() {
    			console.log('demo', this.data);
    		},
    		zudianji() {
    			console.log('组件的点击');
    		},
    		cc(e) {
    			console.log('看看cc有没有东西', e);
    		}
    	}
    };
    </script>
    

      

    子组件书写

    <template>
    	<view>
    		<view class="tianxie-box" @tap="dianji">
    			<view class="tianxie-huizi">{{ huizi }}</view>
    			<input class="tianxie-heizi" :value="value" @input="input_nei($event.target.value)" :placeholder="'请输入' + huizi" type="text" />
    		</view>
    	</view>
    </template>
    
    <script>
    export default {
    	name: 'tianxie',
    	props: {
    		// 灰字
    		huizi: {
    			type: [String, Number],
    			default: ''
    		},
    		//黑字
    		hezi: {
    			type: [String, Number],
    			default: ''
    		},
    		value: {
    			type: [String, Number],
    			default: ''
    		}
    	},
    
    	methods: {
    		dianji() {
    			this.$emit('click');
    		},
    		input_nei(e) {
    			this.$emit('input', e);
    		}
    	}
    };
    </script>
    
    <style scoped lang="scss">
    .tianxie-box {
    	min-height: 180upx;
    	 670upx;
    	margin: 0 auto;
    	box-sizing: border-box;
    	padding-top: 40upx;
    	border-bottom: 1px solid #f1f1f1;
    }
    
    .tianxie-huizi {
    	height: 40upx;
    	line-hegiht: 40upx;
    	font-size: 28upx;
    	font-family: PingFangSC-Regular, PingFang SC;
    	font-weight: 400;
    	color: #999999;
    }
    
    .tianxie-heizi {
    	min-height: 50upx;
    	line-height: 50upx;
    	margin-top: 20upx;
    	font-size: 36upx;
    	font-family: PingFangSC-Regular, PingFang SC;
    	font-weight: 400;
    	color: #333333;
    	overflow: hidden;
    	text-overflow: ellipsis;
    	display: -webkit-box;
    	-webkit-box-orient: vertical;
    	-webkit-line-clamp: 3;
    	 670rpx;
    }
    
    .tianxie-box1 {
    	 670rpx;
    	min-height: 180rpx;
    	margin: 0 auto;
    	display: flex;
    	justify-content: space-between;
    	align-items: center;
    	box-sizing: border-box;
    	padding-top: 40rpx;
    	border-bottom: 1px solid #f1f1f1;
    }
    
    .right_tip {
    	 22rpx;
    	height: 38rpx;
    }
    </style>
    

      

  • 相关阅读:
    Windows性能计数器应用
    Azure Oracle Linux VNC 配置
    Azure 配置管理系列 Oracle Linux (PART6)
    Azure 配置管理系列 Oracle Linux (PART5)
    Azure 配置管理系列 Oracle Linux (PART4)
    Azure 配置管理系列 Oracle Linux (PART3)
    Azure 配置管理系列 Oracle Linux (PART2)
    vagrant多节点配置
    docker基本操作
    LINUX开启允许对外访问的网络端口命令
  • 原文地址:https://www.cnblogs.com/xiaoyaolang/p/14636898.html
Copyright © 2020-2023  润新知