问题:vue中render函数中img的src直接加载路径无效
解决:
js代码:
第一种方案:通过js引入
<script>
//1、引进来
import img1 from "../../../assets/images/u52.png";
export default {
name: "Orgstru",
data() {
return {
columns7: [
{
title: "模板编号",
key: "id",
align: "center"
}
{
title: "操作",
key: "action",
width: 200,
align: "center",
render: (h, params) => {
return h("div", [
h(
"div",
{
style: {
width: "32%",
marginRight: "2%",
display: "inline-block",
color: "#1abc9c"
},
on: {
click: () => {
this.show(params.index);
}
}
},
[
h("img", {
attrs: {
//2、使用
src: img1
},
style: {
width: "17px",
verticalAlign: "middle"
}
}),
"查看"
]
)
]);
}
}
]
};
},
methods: {}
};
</script>
第二种方案:使用base64字符串引用