< 用户:玲子
标签:撤销 已被回退 |
标签:撤销 |
||
第1行: | 第1行: | ||
// 等待页面加载完成 | // 等待页面加载完成 | ||
mw.loader.using( '@wikimedia/codex' ).then( function( require ) { | |||
const Vue = require( 'vue' ); | |||
// 创建 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:44的版本
// 等待页面加载完成
mw.loader.using( '@wikimedia/codex' ).then( function( require ) {
const Vue = require( 'vue' );
// 创建 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');
});