自定义
实现JSX
jsx
// column-text-my.jsx
import { ColumnDefault } from '@yukino-luo/ai-ui'
export default class ColumnMyText extends ColumnDefault {
constructor() {
super()
this.name = 'my-text'
}
getTemplate(config, scope, childConfig) {
return <div style="width: 100%;">My Text</div>
}
}FormDefault对象的方法
| 方法 | 说明 | 参数 | 返回值 |
|---|---|---|---|
| getTemplate | 返回实际渲染组件,子类必须实现 | (config, model) | - |
| getHeader | 返回实际渲染Header | (type, config, model) | - |
| getModelName | 获取model的属性名 | (config) | string |
| getModelValue | 根据属性名获取model对应的值 | (config, model) | object |
| getProp | 获取prop的属性名 | (config, model) | string |
| getColor | 获取自定义颜色 | (config, model) | Function |
| setModelValue | 设置model值,返回一个函数,每当数据更新需要调用这个函数 | (config, model) | Function |
注册JSX
js
// main.js
import { createApp } from 'vue'
import AiUI from '@ai-ui/ui'
import App from './App.vue'
import ColumnMyText from './model/column-text-my.jsx'
createApp(App)
.use((app, options) => {
const tableColumnHook = AiUI.useTableColumn()
tableColumnHook.instance.newModel(ColumnMyText)
})
.mount('#app')