antd 全局修改默认属性方法

直接在main.js里面修改就行
例如modal遮罩层默认关闭

import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import '@/utils/permission/permission'
import './assets/styles/style.less' // global style
import './assets/styles/scroll.less' // global style
import './assets/styles/normalize.css' // normalize style
import './assets/fonts/font.css' //font
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import './assets/styles/merchant.less'
import * as echarts from 'echarts'
import { Modal } from 'ant-design-vue' //引入modal对话框组件
Vue.prototype.$echarts = echarts

Vue.use(Antd)

Vue.config.productionTip = false
Vue.prototype.$eventBus = new Vue()
Modal.props.maskClosable.default = false  //把maskCloseable关闭
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

为了更便于阅读,也可以新建一个config.js ,然后在main.js里引入

/**
 * title: Antd全局组件配置
 * desc: 根据Antd组件属性全局修改其默认值
 * author: nanshen
 * date: 2022-08-15
 */

// 1. 引入需要修改属性默认值的组件
import { TreeSelect } from "ant-design-vue";

// 2. 设置组件属性默认值
TreeSelect.props.treeIcon.default = true;

// 3. 注意, 如果组件没有默认值则需要按如下方式设置:
TreeSelect.props.treeIcon = {type: Boolean, default: true};

你可能感兴趣的:(javascript,vue.js,echarts)