uni-id-pages-x-icons.uvue 1.0 KB
Newer Older
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
1
<template>
DCloud_JSON's avatar
DCloud_JSON 已提交
2
	<view @click="clickHandle">
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
3 4 5 6 7 8
		<text class="uni-id-icon" :style="{color,'fontSize':size + 'px'}">{{iconCode}}</text>
	</view>
</template>

<script>
	export default {
DCloud_JSON's avatar
DCloud_JSON 已提交
9
    emits: ["click"],
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
		props: {
			type: {
				type: String,
				default: "",
				required: true
			},
			color: {
				type: String,
				default: "#ccc"
			},
			size: {
				type: Number,
				default: 16
			},
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
25 26 27 28 29
    methods: {
			clickHandle() {
				this.$emit("click");
			}
		},
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		computed: {
			iconCode() : string {
				const iconCode : UTSJSONObject = {
					"clear": "\ue622",
					"down": "\ue600",
					"right-arrow": "\ue8f1",
					"jiahao": "\ue602",
					"eyes": "\ue62b",
					"advert": "\ue609"
				};
				return iconCode.getString(this.type) as string
			}
		},
		data() {
			return {}
		}
	}
</script>

<style>
	@font-face {
		font-family: "uni-id-icon";
    src: url('/uni_modules/uni-id-pages-x/static/fonts/uni-id-icon.ttf');
	}

	.uni-id-icon {
		font-family: "uni-id-icon";
		font-size: 16px;
		font-style: normal;
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
60
</style>