< 用户:玲子
| 无编辑摘要 | 无编辑摘要 | ||
| 第1行: | 第1行: | ||
| (function() { | |||
|     'use strict'; | |||
| mw.loader.using( ' |     // 等待页面加载完成 | ||
|     mw.loader.using(['vue', 'codex']).then(function() { | |||
|         // 创建 Vue 应用 | |||
|         const app = Vue.createApp({ | |||
|             data() { | |||
|                 return { | |||
|                     showDialog: false | |||
|                 } | |||
|             }, | |||
|             methods: { | |||
|                 openDialog() { | |||
|                     this.showDialog = true; | |||
|                 }, | |||
|                 closeDialog() { | |||
|                     this.showDialog = false; | |||
|                 } | |||
|             }, | |||
|             template: ` | |||
|                 <div> | |||
|                     <cdx-button | |||
|                         weight="primary" | |||
|                         @click="openDialog" | |||
|                     > | |||
|                         打开对话框 | |||
|                     </cdx-button> | |||
|                     <cdx-dialog | |||
|                         v-model:open="showDialog" | |||
|                         title="提示" | |||
|                         @close="closeDialog" | |||
|                     > | |||
|                         <p>这是一个使用 Codex 和 Vue 实现的对话框示例。</p> | |||
|                         <template #footer> | |||
|                             <cdx-button | |||
|                                 weight="primary" | |||
|                                 @click="closeDialog" | |||
|                             > | |||
|                                 确定 | |||
|                             </cdx-button> | |||
|                         </template> | |||
|                     </cdx-dialog> | |||
|                 </div> | |||
|             ` | |||
|         }); | |||
|         // 创建容器元素 | |||
|         const container = document.createElement('div'); | |||
|         container.id = 'codex-demo'; | |||
|         document.body.appendChild(container); | |||
|         // 挂载 Vue 应用 | |||
| } ); |         app.mount('#codex-demo'); | ||
|     }); | |||
| })(); | |||
2025年5月28日 (三) 20:32的版本
(function() {
    'use strict';
    // 等待页面加载完成
    mw.loader.using(['vue', 'codex']).then(function() {
        // 创建 Vue 应用
        const app = Vue.createApp({
            data() {
                return {
                    showDialog: false
                }
            },
            methods: {
                openDialog() {
                    this.showDialog = true;
                },
                closeDialog() {
                    this.showDialog = false;
                }
            },
            template: `
                <div>
                    <cdx-button
                        weight="primary"
                        @click="openDialog"
                    >
                        打开对话框
                    </cdx-button>
                    <cdx-dialog
                        v-model:open="showDialog"
                        title="提示"
                        @close="closeDialog"
                    >
                        <p>这是一个使用 Codex 和 Vue 实现的对话框示例。</p>
                        <template #footer>
                            <cdx-button
                                weight="primary"
                                @click="closeDialog"
                            >
                                确定
                            </cdx-button>
                        </template>
                    </cdx-dialog>
                </div>
            `
        });
        // 创建容器元素
        const container = document.createElement('div');
        container.id = 'codex-demo';
        document.body.appendChild(container);
        // 挂载 Vue 应用
        app.mount('#codex-demo');
    });
})();