我正在尝试将图像 src 动态绑定到表单的 URL ../assets/project_screens/image_name.jpg。
我的目录结构如下:
- src
-- assets
---- project_screens
-- profile
---- ProjectList.vue
-- store
---- profile.js
Run Code Online (Sandbox Code Playgroud)
我知道我需要使用 webpackrequire("path/to/image")来帮助 webpack 构建这些图像,但是路径没有解析。
- src
-- assets
---- project_screens
-- profile
---- ProjectList.vue
-- store
---- profile.js
Run Code Online (Sandbox Code Playgroud)
// store/profile.js
projects = [
{
....
},
{
....
img_url: "../assets/project_screens/im1.jpg"
....
}
....
]
Run Code Online (Sandbox Code Playgroud)
如果我使用 URL 字符串而不是动态传递 URL 字符串,它会起作用。环顾堆栈溢出,没有任何解决方案有帮助。我还缺少其他东西吗?