我正在使用以下内容:
props: {
backgroundImagePath: {
type: String,
required: true,
default: '@/static/images/9.jpeg'
}
}
:style="{
backgroundImage: `url(${require(backgroundImagePath)})`
}"
这给我以下错误:
找不到模块'@ / static / images / 9.jpeg'
:style="{
backgroundImage: `url(${require('@/static/images/9.jpeg')})`
}"
但是正常工作-我不确定为什么吗?
对于上下文,我正在使用NuxtJS。
props: {
backgroundImagePath: {
required: true,
default: require('@/static/images/9.jpeg')
}
}
:style="{
backgroundImage: `url(${backgroundImagePath})`
}"
更改backgroundImagePath
prop默认值似乎可以解决此问题。