Laravel 5.5中使用laravel-mix的SweetAlert无法正常使用css

时间:2017-12-03 08:26:19

标签: laravel-5 laravel-mix sweetalert2

我尝试在Larvel Mix中使用Laravel 5.5 SweetAlert,但无法正常工作

webpack.mix.js

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .copy('node_modules/sweetalert/dist', 'public/js');

package.json

 "devDependencies": {
        ...
        "bootstrap-sass": "^3.3.7",
        ...
        "jquery": "^3.2",
        "laravel-mix": "^1.0",
        "sweetalert": "^2.0.8",

资源/资产/ SASS / app.css

// Sweet Alert
@import url("https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css");

当我执行npm run dev编译时没有任何错误。

但是当我使用这种方法时,警报会显示没有SweetAlert的CSS样式。

3 个答案:

答案 0 :(得分:0)

resources/assets/sass/app.scss文件中,

请改用此行

@import "~sweetalert2";

您正在做的事情(从CDN导入CSS)与npm完全无关。

答案 1 :(得分:0)

第1步:npm install sweetalert --save在终端/ cmd中运行此命令。

步骤2:在您的resources/js/app.js文件中,只需将其导入应用程序import swal from 'sweetalert';

enter image description here

答案 2 :(得分:0)

之后

        public static LocalDate GetOriginalDate(this AppointmentItem appointment)
        {
            // The original date is stored in a property called ExceptionReplaceTime but this
            // property is not exposed in the OOM so we need to use PropertyAccessor
            // See: https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidexceptionreplacetime-canonical-property
            using (var props = appointment.PropertyAccessor.AsOwnedResource())
            {
                var p = props.Resource.GetProperty("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82280040");
                DateTime exceptionReplaceTime = (DateTime)p;
                return props.Resource.UTCToLocalTime(exceptionReplaceTime).ToLocalDate();
            }
        }

您应该在app.js中执行以下操作:

npm install sweetalert2 --save