<span v-if="$slots.default"><slot></slot></span>
</button>
可发现是
$attrs 覆盖了
el-button 的nativeType问题简化重现
<el-form ref="form" :model="form" label-width="80px">
<el-form-item>
<button type="primary">点击会刷新</button>
<button type="button" @click="onSubmit">点击不会刷新</button>
</el-form-item>
</el-form>重现链接
解决方法
将
type 分出来
props ,然后再通过 prop 引用
<template>
<el-button
:type="type"
v-show="validButton"
v-bind="$attrs"
v-on="$listeners"
>
<slot></slot>
</el-button>
</template><script>
import { mapGetters } from 'vuex';
import env from '@/config/env';
export default {
props: {
// 按钮唯一标识
buttonId: {
type: String,
required: true,
},
type: {
type: String,
}
},
computed: {
...mapGetters(['getUserBtns']),
validButton: function() {
return env.debug ? true : this.getUserBtns[this.buttonId];
},
},
};
</script>










