<template>
	<icon-comp :img="checkedValue ? 'checked' : 'unchecked'" size="32" @click.stop="clickRadio"/>
</template>

<script>
import iconComp from './icon.vue'

export default {
	components: {iconComp},
	props: {
		checked: {//默认是否选中
			type: Boolean,
			default: false,
		},
	},
	computed: {
		checkedValue() {//要放到这里，这样才会和外部的数据同步
			return this.checked
		}
	},
	data() {
		return {
			// checkedValue: this.checked,
		}
	},
	methods: {
		clickRadio() {
			// this.checked = !this.checked //不能修改prop，不然会报错
			this.$emit("change", !this.checked) //由外部去同步这个数据
		},
	},
}
</script>

<style>
</style>