Vue读不了assets下的vuex里面存的相对路径

$this.store和require不能一起使用

那就让他去读服务器上的图片

springboot代码:

从别人那搜的

package test.test.tool;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        //上传的图片在D盘下的img目录下,访问路径如:http://localhost:8081/img/mrtx.jpg
        //其中img表示访问的前缀。"file:D:/img/"是文件真实的存储路径
        registry.addResourceHandler("/img/**").addResourceLocations("file:D:/img/");
    }
}

 

现在我就能从网页访问头像的地址了Vue读不了assets下的vuex里面存的相对路径

Vue读不了assets下的vuex里面存的相对路径

 

Vue读不了assets下的vuex里面存的相对路径