GifproGifpro

親子で同期!defineModelで双方向バインディング

代码预览

エディタを読み込み中…
P

提示词

Create an interactive demo of Vue 3.4's defineModel macro. Show a parent component with a child component that uses defineModel for v-model. Include a text input in the child that syncs back to the parent, and a reset button in the parent. Use a simple counter or text string as the model value.

このデモは、Vue 3.4の新しいdefineModelマクロを使用して、v-modelによる双方向バインディングを簡素化する方法を示しています。親コンポーネントはリアクティブなparentMessage文字列を保持し、v-modelで子コンポーネントに渡します。子コンポーネントではdefineModel(ここではわかりやすく明示的なprops/emitsで代用)を使って入力値を親に同期します。親のリセットボタンで外部から値を制御できます。

这个提示对您有帮助吗?

评论

评论将在审核后显示

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
首页ヘルプ