Vue DevExtreme 组件语法

2023年 10月 1日 87.0k 0

环境搭建
参考

Vue DevExtreme 环境搭建 - 掘金 (juejin.cn)

组件

按钮

image.png

创建一个按钮,并且绑定点击事件


      



import DxButton from 'devextreme-vue/button';
 
 const sayHelloWorld = () => {
     alert('Hello world!')
 }

条形图

image.png


  
      
      
      
      
  



import DxChart, {
  DxArgumentAxis,
  DxSeries,
  DxLegend,
  DxTooltip
} from 'devextreme-vue/chart';

const data = [{
  arg: 1990,
  val: 5320816667
}, {
  arg: 2000,
  val: 6127700428
}, {
  arg: 2010,
  val: 6916183482
}];


列表

image.png


  
      
          
              Available items
          
      
      
          
              {{ item.text }}
          
      
  



import DxList, {
  DxItem
} from 'devextreme-vue/list';

const listItems = [{
  text: 'Cars',
  badge: '12'
}, {
  text: 'Bikes',
  badge: '5'
}];

提示框

image.png


  



import DxButton from 'devextreme-vue/button';
import notify from 'devextreme/ui/notify';

const okClicked = (e) => {
  notify('The OK button was clicked')
}

单向绑定

即使值已经修改,也无法获取修改后的值

image.png


  
  




import { ref } from "vue";

import DxButton from 'devextreme-vue/button';
import DxTextBox from 'devextreme-vue/text-box';

let bindingProperty = ref('Some value');

const click = ()=>{
  console.log(bindingProperty.value)
}


双向绑定

image.png


  
  




import { ref } from "vue";

import DxButton from 'devextreme-vue/button';
import DxTextBox from 'devextreme-vue/text-box';

let bindingProperty = ref('Some value');

const click = ()=>{
  console.log(bindingProperty.value)
}


表单验证

image.png


  
      
          
              
              
          
      

      
          
              
          
      

      

      
  



import DxTextBox from 'devextreme-vue/text-box';
import DxValidator, {
  DxRequiredRule,
  DxEmailRule
} from 'devextreme-vue/validator';
import DxValidationGroup from 'devextreme-vue/validation-group';
import DxValidationSummary from 'devextreme-vue/validation-summary';
import DxButton from 'devextreme-vue/button';

let email = undefined;
let password = undefined;

const validate = (params) => {
  let result = params.validationGroup.validate();
  if (result.isValid) {
      // the values are valid
      // submit and reset them
      // params.validationGroup.reset();
      console.log(result);
  }
}

相关文章

JavaScript2024新功能:Object.groupBy、正则表达式v标志
PHP trim 函数对多字节字符的使用和限制
新函数 json_validate() 、randomizer 类扩展…20 个PHP 8.3 新特性全面解析
使用HTMX为WordPress增效:如何在不使用复杂框架的情况下增强平台功能
为React 19做准备:WordPress 6.6用户指南
如何删除WordPress中的所有评论

发布评论