angular image url找不到问题

1、首先添加资源文件配置,angular.json --> options -->  assets 添加: "src/assets"

2、index.html里: <base href="/">

2、ts/html中 url要写相对路径: assent/image/a.png (前边 "./" 可以不写)

3、less里这样写 background:~'url("../../assent/image/a.png")'   

说明:

  • 如果less中:“background-image: url('assets/event-bg.png');”  会报CssSyntaxError。
  • 如果: “ackground-image: url('../../../assets/event-bg.png');”  会报not found。

 less中 "~"符号,表示编译时不计算。

扫描二维码关注公众号,回复: 11798563 查看本文章
  • 例如less中这样写: width:~'calc(300px-30px)';, 编译成css后是:width: calc(300px-30px);
  • 例如less中这样写: width:calc(300px-30px);, 编译成css后是:width: calc(270px);

猜你喜欢

转载自blog.csdn.net/u013475983/article/details/89294120