コンポーネントに親要素のinputからpropsを通して得た値を
computedのgetter, setterで更新して受け渡すという処理をtypescriptで実現できません。
ご教示頂ければと思います。
エラー内容
bash
1A 'set' accessor cannot have a return type annotation.
ソース内容
ts
1export default class FilterBar extends Vue { 2 @Prop({ type: String, required: false, default: '' }) value!: string 3 // data 4 valued: string = this.value 5 // computed 6 get internalValue(): string { 7 return this.valued 8 } 9 // set時にエラーがでる 10 set internalValue(newVal: string): void { 11 if (this.valued !== newVal) { 12 this.valued = newVal 13 this.$emit('input', newVal) 14 } 15 } 16}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。