SyntaxError:预期表达式,get'<';main.js yii2
我的yii2 web应用程序的首页乱七八糟。我不太清楚为什么。它在localhost中运行得非常好。当我将其移动到服务器时,它会显示不同的内容。页脚已向上移动,jumbotrons未居中等。 就像下面-SyntaxError:预期表达式,get'<';main.js yii2,yii2,Yii2,我的yii2 web应用程序的首页乱七八糟。我不太清楚为什么。它在localhost中运行得非常好。当我将其移动到服务器时,它会显示不同的内容。页脚已向上移动,jumbotrons未居中等。 就像下面- 控制台中有一个错误-SyntaxError:预期表达式,得到“您在main.JS中的JS代码有错误,请附加此文件的一些内容。有问题的更新了main.JS文件。这是您的JS文件中唯一的代码吗?没有脚本标记?您是否在控制器中使用任何其他资产?您提供的html来自代码或查看页面源代码?单击main.
控制台中有一个错误-
SyntaxError:预期表达式,得到“您在main.JS
中的JS代码有错误,请附加此文件的一些内容。有问题的更新了main.JS文件。这是您的JS文件中唯一的代码吗?没有脚本标记?您是否在控制器中使用任何其他资产?您提供的html来自代码或查看页面源代码?单击main.js链接后,在错误消息上,我得到了问题中的html。它是由/layout/main.php和/site/view/index.phpca组合而成的。请将视图文件和布局附在一起好吗?
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-param" content="_csrf">
<title>G.M.Pharmaceuticals</title>
<link href="/assets/4ec4bebd/css/bootstrap.css" rel="stylesheet">
<link href="/css/site.css" rel="stylesheet">
</head>
<body>
<div class="wrap">
<nav id="w0" class="navbar-inverse navbar-fixed-top navbar"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w0-collapse"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button><a class="navbar-brand" href="/index.php">GM Pharmaceuticals</a></div><div id="w0-collapse" class="collapse navbar-collapse"><ul id="w1" class="navbar-nav navbar-right nav"><li class="active"><a href="/index.php?r=site%2Findex">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Menu <span class="caret"></span></a><ul id="w2" class="dropdown-menu"></ul></li>
<li><a href="/index.php?r=site%2Fsignup">Signup</a></li>
<li><a href="/index.php?r=site%2Flogin">Login</a></li></ul></div></div></nav>
<div class="container-fluid">
<ul class="breadcrumb"><li><a href="/index.php">Home</a></li>
<li class="active">G.M.Pharmaceuticals</li>
<li class="active">G.M.Pharmaceuticals</li>
</ul>
<div class="site-index">
<div class="jumbotron">
<h1>Welcome to G.M.Pharmaceuticals</h1>
<p class="lead">Please contact the system Administrator for credentials</p>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">© GM Pharmaceuticals 2018</p>
<p class="pull-right">Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></p>
</div>
</footer>
<script src="/assets/7821041f/jquery.js"></script>
<script src="/assets/87474ea6/yii.js"></script>
<script src="/js/main.js"></script>
<script src="/assets/4ec4bebd/js/bootstrap.js"></script></body>
</html>
$(function(){
$('#modalButton').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
});
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
$this->title = 'G.M.Pharmaceuticals';
$this->params['breadcrumbs'][] = $this->title;
//$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-index">
<div class="jumbotron">
<h1>Welcome to G.M.Pharmaceuticals</h1>
<p class="lead">Please contact the system Administrator for credentials</p>
</div>
</div>
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use common\widgets\Alert;
use kartik\sidenav\SideNav;
use yii\helpers\Url;
AppAsset::register($this);
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => 'GM Pharmaceuticals',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
.......
// ['label' => 'About', 'url' => ['/site/about']],
// ['label' => 'Contact', 'url' => ['/site/contact']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
];
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
<div class="container-fluid">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= Alert::widget() ?>
<?= $content ?>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">© GM Pharmaceuticals <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/main.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
public function actionIndex()
{
return $this->render('index');
}