mirror of
https://github.com/vxcontrol/ncform.git
synced 2026-07-22 06:45:23 -04:00
226 lines
6.3 KiB
JavaScript
Executable File
226 lines
6.3 KiB
JavaScript
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
|
|
<title>textarea widget</title>
|
|
|
|
<link rel="stylesheet" href="../demo.css" />
|
|
|
|
<!-- 引入样式 -->
|
|
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
|
|
|
|
<script>
|
|
var _hmt = _hmt || [];
|
|
(function() {
|
|
var hm = document.createElement("script");
|
|
hm.src = "https://hm.baidu.com/hm.js?027aa17f0e14133f0b8aa5f1f0af3ca7";
|
|
var s = document.getElementsByTagName("script")[0];
|
|
s.parentNode.insertBefore(hm, s);
|
|
})();
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<!--演示区域-->
|
|
<div id="demo" v-cloak>
|
|
<div v-for="(item, idx) in formSchemas">
|
|
<h4 class="demo_title">{{ item.title }}</h4>
|
|
<div class="demo_item-wrapper">
|
|
<div>
|
|
<ncform :form-schema="item.schema" v-model="item.schema.value"></ncform>
|
|
<small>value: {{ item.schema.value }}</small>
|
|
</div>
|
|
<div>
|
|
<pre>{{ JSON.stringify(originFormSchemas[idx].schema.properties, null, 2) }}</pre>
|
|
</div>
|
|
<div>
|
|
<pre>{{ item.detail }}</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
|
<script type="text/javascript" src="../../node_modules/axios/dist/axios.min.js"></script>
|
|
<script type="text/javascript" src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
|
|
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
|
|
<script type="text/javascript" src="../../node_modules/@ncform/ncform-common/dist/ncformCommon.min.js"></script>
|
|
<script type="text/javascript" src="../../node_modules/@ncform/ncform/dist/vueNcform.js"></script>
|
|
<script type="text/javascript" src="../../dist/textarea.js"></script>
|
|
<script type="text/javascript" src="../../dist/object.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
let lang = 'en';
|
|
|
|
if (location.search.indexOf('lang=cn') >= 0) {
|
|
lang = 'cn';
|
|
}
|
|
|
|
Vue.use(vueNcform, { extComponents: { object: object.default, textarea: textarea.default }, lang: lang === 'cn' ? 'zh_cn' : 'en' });
|
|
|
|
let formSchemas = [
|
|
{
|
|
title: {
|
|
cn: '默认状态',
|
|
en: 'Default'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
ui: {
|
|
widget: 'textarea'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '提供值',
|
|
en: 'Provide value'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
value: 'hello world.',
|
|
ui: {
|
|
widget: 'textarea'
|
|
}
|
|
}
|
|
},
|
|
ui: {
|
|
widgetConfig: {
|
|
layout: 'h'
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '[属性] readonly: 只读状态',
|
|
en: '[ATTR] readonly: read-only state'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
value: 'hello world.',
|
|
ui: {
|
|
widget: 'textarea',
|
|
readonly: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '[属性] disabled: 禁用状态',
|
|
en: '[ATTR] disabled: disable state'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
value: 'hello world.',
|
|
ui: {
|
|
widget: 'textarea',
|
|
disabled: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '[属性] rows: 行数. 默认值: 2',
|
|
en: '[ATTR] rows: number of rows. Default is 2'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
ui: {
|
|
widget: 'textarea',
|
|
widgetConfig: {
|
|
rows: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '[属性] autoSize: 自动伸缩. 默认值: false',
|
|
en: '[ATTR] autoSize: auto-stretch. Default is false'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
message: {
|
|
type: 'string',
|
|
ui: {
|
|
widget: 'textarea',
|
|
widgetConfig: {
|
|
rows: 3,
|
|
autoSize: {
|
|
minRows: 2,
|
|
maxRows: 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
title: {
|
|
cn: '[属性] updateOn: 触发值更新的时机,默认是输入变化即触发。可选值:["change", "blur"]',
|
|
en: '[ATTR] updateOn: timing of triggering value changes, the default is to trigger when value changed. Optional value: ["change", "blur"]'
|
|
},
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
ui: {
|
|
widget: 'textarea',
|
|
widgetConfig: {
|
|
updateOn: 'blur'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
];
|
|
|
|
// Bootstrap the app
|
|
new Vue({
|
|
el: '#demo',
|
|
data: {
|
|
formSchemas: getFormSchemas(),
|
|
originFormSchemas: getFormSchemas()
|
|
}
|
|
});
|
|
|
|
function getFormSchemas() {
|
|
return formSchemas.map(item => ({
|
|
title: item.title[lang],
|
|
schema: item.schema,
|
|
detail: item.detail ? item.detail[lang] : ''
|
|
}));
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|