声明|定义字典

在单文件组件中组合式声明或配置字典

启用

如组件内初始时无字典配置,后期动态注册字典open in new window,也需在选项中声明启用字典,此时字典配置为空

  • 示例
export default {
  dicts: []
}

声明

声明字典

将在插件选项open in new window中寻找字典配置,并以回退字典open in new window下所有属性作为缺省配置

  • 示例
<script setup>
  defineOptions({
    dicts: ['lang'],
  })
<script>

定义

定义字典

在组件内局部定义字典,参见字典选项open in new window

  • 示例
<script setup>
  defineOptions({
    dicts: [
      {
        type: 'lang',
        request(dictMeta) {
          return Promise.resolve([
            { label: 'js', value: 1 },
            { label: 'java', value: 2 },
            { label: 'c', value: 3 },
          ])
        },
        responseConverter(response, dictMeta) {
          return response.map(e => VueDataDict.convertData(e, dictMeta))
        },
        labelField: 'label',
        valueField: 'value',
        lazy: false,
        lookup: false,
      }
    ]
  })
<script>