首页 > 解决方案 > 一种在本地环境中使用asset(mix(file.js)) 的方法

问题描述

从这里切换我的资产加载后:

    <!-- Scripts -->
    <script src="js/index.js" defer></script>
    <!-- Styles -->
    <link href="css/app.css" rel="stylesheet">
    <link href="css/fonts.css" rel="stylesheet">
    <link href="css/container.css" rel="stylesheet">

对此:

    <!-- Scripts -->
    <script src="{{ asset(mix('/js/index.js'), true) }}" defer></script>
    <!-- Styles -->
    <link href="{{ asset(mix('/css/app.css'), true) }}" rel="stylesheet">
    <link href="{{ asset(mix('/css/fonts.css'), true) }}" rel="stylesheet">
    <link href="{{ asset(mix('/css/container.css'), true) }}" rel="stylesheet">

然后当试图访问 http://localhost 它只是抛出Failed to load resource: net::ERR_CONNECTION_REFUSED. 我知道这是我的本地站点一直在使用 HTTP 而不是 HTTPS。但是有没有任何便宜的解决方案可以在不为 localhost 设置 HTTPS 的情况下完成这项工作?

标签: laravellaravel-mix

解决方案


推荐阅读