<style lang=sass>
@import "../../assets/components/_radio.scss";
</style>

<template>
<label class="radio">
	<span class="radio-inner">
		<input :name="name" :value="value" class="radio-input" type="radio" :disabled="disabled" :checked="checked" @change="onChanged"/>
		<i class="radio-icon"></i>
	</span>
	<span class="radio-text">{{text}}</span>
</label>
</template>

<script>
export default{
	props:{
		name:String,
		checked:String,
		disabled:String,
		text:String,
		value:String,
		option:Object//继承父组件传递的options参数
	},
	data(){
		return{
			
		}
	},
	created(){
		var _option=this.option;
		if(_option!=undefined){
			this.name=_option.name;
			this.checked=_option.checked=="checked"?"checked":null;
			this.disabled=_option.disabled=="disabled"?"disabled":null;
			this.text=_option.text!=undefined?_option.text:"";
			this.value=_option.value!=undefined?_option.value:"";
		}
	},
	methods:{
		onChanged(){
			this.checked="checked";
			this.$emit("changed",{
				value:this.value,
				text:this.text,
				checked:this.checked
			});
		}
	}
}

</script>