使用vue2和gh-pages纠正img路径

时间:2019-03-17 17:56:39

标签: path vuejs2 github-pages vue-cli

使用

 choice = " "
 while choice != 'Y' or choice != 'N' :
      choice = input("Y for Yes or N for No")

我尝试了几种方法来获取vue项目中的图像在gh页中工作的正确路径。

"vue": "^2.6.8" 
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^2.9.7",
"webpack-merge": "^4.2.1"

但是它们都不起作用。

我尝试了@ / assets / previewImages / SAD-1.jpg,但这在编译时会出现错误。

我也看过各种posts,但无济于事。

该项目使用推送到gh页

.div-bg
    {
        background-image: url("../assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    }
.div-bg1
    {
        background-image: url("/src/assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    }
.div-bg2
    {
        background-image: url("~/src/assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    }
.div-bg3
    {
        background-image: url("/assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    }
.div-bg4
    {
        background-image: url("~/assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    }
/* .div-bg5
    {*/
        /* background-image: url("../assets/previewImages/test.jpg");*/
      /*  background-image: url("@/assets/previewImages/SAD-1.jpg");
        height: 570px;
        width: 1020px;
    } */

谢谢

0 个答案:

没有答案