方法一:require 引入
<template>
<img :src="logo1" class="sidebar-logo" v-if="logo1" />
</template>
<script>
export default {
data() {
return {
logo1: require("../../../assets/images/logo1.png"), // 或 logo1: require("@/assets/images/logo1.png")
}
}
}
</script>
<style lang="scss" scoped>
</style>
方法二:import引入
<template>
<img :src="logo1" class="sidebar-logo" v-if="logo1" />
</template>
<script>
import logo1 from '@/assets/images/logo1.png'
export default {
data() {
return {
logo1
}
}
}
</script>
<style lang="scss" scoped>
</style>
方法三:组件背景图片
<template>
<d