1、在template中编写如下代码
(ps:input 不能设置disabled属性或者type类型为hidden值)
<el-input id="copydom" v-model.number="ruleForm.passport" :readonly="isDis" placeholder="请输入密码"></el-input>
<el-button type="success" @click="copyPassword">
复制密码
</el-button>
2、在script 的methods里加入如下方法:
copyPassword() {
let dom = document.getElementById("copydom")
dom.select();
document.execCommand("Copy");
this.$notify({
message: "复制成功"
});
},
网友评论