HTML 代码:
<div> <div> <img :src="picture" /> </div> <div @mouseover="everMouseover()" @mouseleave="elevMouseleave()" ></div> </div>
CSS 代码:
.main { height: 300px; width: 100px; } .imgs { height: 100%; } .a { background-color: brown; width: 200px; height: 100px; }
JS 代码:
export default { data() { return { imgObj: { immigrate: require("./img/tu1.jpeg"), shift_out: require("./img/tu2.jpeg"), }, picture: require("./img/tu1.jpeg"), }; }, model: { //鼠标移入触发 everMouseover: function () { this.picture = this.imgObj.immigrate; }, //鼠标移出触发 elevMouseleave: function () { this.picture = this.imgObj.shift_ouf; }, }, };