This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default { | |
| data: () => ({ | |
| count: 0 | |
| }), | |
| methods: { | |
| increment() { | |
| this.count++; | |
| } | |
| }, | |
| computed: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template><!--省略--></template> | |
| <script> | |
| import useCounter from "./useCounter"; | |
| export default { | |
| setup() { | |
| const { count, double, increment } = useCounter(); | |
| return { | |
| count, | |
| double, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { reactive, computed } from "vue"; | |
| export default function { | |
| const state = reactive({ | |
| count: 0, | |
| double: computed(() => state.count * 2) | |
| }); | |
| function increment() { | |
| state.count++; | |
| } | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <!-- 省略 --> | |
| <template> | |
| <script> | |
| import { reactive, computed } from "vue"; | |
| export default { | |
| setup() { | |
| const state = reactive({ | |
| count: 0, | |
| double: computed(() => state.count * 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <button @click="increment"> | |
| <div>Count: {{ count }}</div> | |
| <div>Double: {{ double }}</div> | |
| </button> | |
| <template> | |
| <script> | |
| export default { | |
| data: () => ({ | |
| count: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <!-- 省略 --> | |
| </template> | |
| <script> | |
| import CommonFunction from "./CommonFunction"; | |
| export default { | |
| name: 'MyComponent', | |
| methods: { | |
| CommonFunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function () { | |
| // ここに共通処理を書く。 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <my-component> | |
| <div>コンポーネントの外側から挿入したい要素</div> | |
| <my-component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div> | |
| <div>サンプル</div> | |
| <slot /> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'MyComponent' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- template A と表示する。 --> | |
| <my-component sampleProp="1"></my-component> | |
| <!-- template B と表示する。 --> | |
| <my-component sampleProp="2"></my-component> |