0.12.0 • Published 4 years ago
etadmin-common v0.12.0
etadmin-common
Installing
npm:
$ npm install etadmin-common
cdn:
<script src="etadmin.js"></script>
<script src="https://treeast.com/assets/script/etadmin.common.min.js"></script>
Example
note: CommonJS usage
Http
// 1.
return config
// 2. Promise
return new Promise(resolve => {
resolve(config)
})
// 3. async/await
return (async () => {
await $$.module.organization.api.list({
success: data => {
console.log('...data', data)
}
})
return config
})()
// 各种取数据
// $$.module.organization.api.view({
// data: { id: id },
// success: data => {
// this.value = data
// }
// })
// .then(data => {
// $$.log('...data', data)
// })
// .catch(error => {
// $$.log('...error', error)
// })
// .finally(() => {
// $$.log('....finally')
// })
// 各种关闭方法
// <template #action="{data, close}">
// <Action @click="data.visible = false">关闭</Action>
// <Action @click="close()">关闭</Action>
// <Action @click="onClose()">关闭</Action> <!-- <PageView :visible="visible"> -->
// </template>
Module
// 抽象出 数据、组件、API
const xxx = {
name: 'xx', // 名称
data, // 数据(解构) $ -> 源
component, // 组件(解构) $ -> 源
api, // API $ -> 源
config: { // 配置 子类继承
http, // http
menu, // 菜单
layout, // 布局
compine, // 编译回掉 api, component
}
}
2.0
每个模块一个对象,对象 $name $data $component $api $config $http $menu +hook
const root = new Module({ name: 'xxx' })
// 父类编译
root.comp()
// 单独编译后挂载