Aiden
Aiden

Reputation: 35

Yii2 framework loaded js file return errors

I using yii2 AppAsset component registered js file:

<?php

namespace backend\assets;

use yii\web\AssetBundle;

class DiyAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl  = '@web';
    public $css = [
        //'css/diy.css',
    ];
    public $js = [
        'js/base.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];

}

the js file content: the js file content

the js file loaded success,but chrome broswer show me the error:

show erros

expland erros

can everyboy help me?

Upvotes: 2

Views: 114

Answers (2)

Geoff
Geoff

Reputation: 6639

From the above discussion i can guess that there might be a problem with your yii2 generated asset files, ive tried duplicating your error but without success,

I had also got such an error before when i copy pasted a previous app to start developing another app from that, The way i solved it was to delete the generated assets files as yii2 will recreate the files when you run the application again

If you are using the advanced template

The assets to delete are located at the root directory that is the directory structure looks like

_protected
assets //delete the contents in here but dont delete the folder assets
backend
themes
uploads
 ....etc

I hope this helps

Upvotes: 0

SilverFire
SilverFire

Reputation: 1592

Most probably you use VirtualBox to run Yii2 application.

If yes - disable sendfile in your Apache or Nginx config. Check out this issue on GitHub

Upvotes: 1

Related Questions