Loading in local fonts with webpack 2 and the vue-cli

前端 未结 2 1365
[愿得一人]
[愿得一人] 2021-01-02 11:48

I\'m using the vue-cli webpack template and I\'m trying to load in local fonts in my project. I\'m having trouble getting the path to my fonts correct. How should my path lo

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 12:34

    In the vuejs project I am working on,

    This one did not worked:

    @font-face {
       font-family: 'name-of-choice';
       src: url("~@/assets//font-file-name.ttf") format('font-type');
    }
    

    This worked:

    @font-face {
       font-family: 'name-of-choice';
       src: url(~@/assets//font-file-name.ttf) format('font-type');
    }
    

    And I've observed that if we use the solution without double quote for one single time and then add double quotes, it again works! If anyone know what's happening here, please do answer.

    Solution: Try not enclosing URL String in quotes.

提交回复
热议问题