<template> <div class=''></div> <img :src="icon" alt=""> </template> <script> export default { data(){ return{ // 加require即可 icon:require('../assets/images/icon.png') } } } </script> <style lang="less" scoped> </style>
assets下的静态文件会被webpack编译,而static下的文件会直接复制不编译
参考地址1 https://www.cnblogs.com/edwardwzw/p/13141868.html
参考地址2 https://www.jb51.net/article/171481.htm