一、若是这些产品图片文件“万年不变”,放在 /static 目录里,(不须要使用require将这些图片做为模块来引用)webpack
var products = [{ img: '/static/img/products/1.png', name: 'Product 1' }, { img: '/static/img/products/2.png', name: 'Product 2' }, { img: '/static/img/products/3.png', name: 'Product 3' }, { img: '/static/img/products/4.png', name: 'Product 4' }]
二、Vue实例数据的数组中只会保存图片文件路径,经过webpack打包不会将图片拷贝到dist目录中,因此本着模块化的思想下,应该用require来引用web
var products = [{ img: require('@/assets/products/1.png'), name: 'Product 1' }, { img: require('@/assets/products/2.png'), name: 'Product 2' }, { img: require('@/assets/products/3.png'), name: 'Product 3' }, { img: require('@/assets/products/4.png'), name: 'Product 4' }]