未检测到 Vuejs

Posted

技术标签:

【中文标题】未检测到 Vuejs【英文标题】:Vuejs is not detected 【发布时间】:2018-12-11 03:04:06 【问题描述】:

大家好,请帮忙!在我的页面上未检测到 Vue js。我不知道为什么。我过去构建了很多 vueapps,以前从未遇到过问题。我想知道引导 js 是否与 vuejs 冲突?我加载页面,当我尝试进入 chrome 开发工具时,它说未检测到 vuejs。脑洞大开!有什么想法吗?

 <?php ob_start(); session_start();
if (isset($_SESSION['activated'])) 
    $activated = $_SESSION['activated'];
  

  if (isset($activated) && $activated == 0) 
    echo '<script type="text/javascript">';
    echo 'alert("Please activate your account before signing in. ");';
    echo 'window.location.href = "resendoptions.php?userName=' . $_SESSION[username] . '";';
    echo '</script>';
  

  if (isset($_SESSION['success']) and $_SESSION['success'] == 1) 
    $success = 1;
  
  else 
    $success = 0;
  

?>
<html>
<head>
    <style>
        nav a
            color: white
        
        nav background-color: #1c71b9; 
        .navbar-toggleborder: 3px solid white;
        .icon-barbackground-color: white;
        .navbar-brand:hoverbackground-color: white;
        color: #1c71b9;
        
        bodymargin-top: 50px;
        h1, h2, h3, h4, h5, h6, p
            -webkit-font-smoothing: antialiased;
            text-rendering: optimizeLegibility;
        
        .row + .rowmargin-top: 20px;
        .itemHeadingfont-weight: bold;
        .icondisplay: block; max-width: 100%; margin-top: 10px;
        .descriptionHeadingmargin-top: 20px; text-align: center;
        .descriptionSectionbackground-color: lightgray;
        .mainDescriptionHeadingtext-align: center;
        .descriptionParagraphtext-align: center;
        .centerDescriptionButtonpadding-bottom: 20px;
        .first-slide videowidth: 100%;
        .second-slide videowidth: 100%;
        .third-slide videowidth: 100%;
        .first-slidewidth: 100%;
        .second-slidewidth: 100%;
        .third-slidewidth: 100%;
        #myCarouselmargin-top: 50px;
        .cardwidth: 100%; margin-bottom: 30px; box-shadow: 0 0 5px; padding: 15px;
        .card videowidth:100%;
        .card-titlefont-weight: bold;

        .errorcolor: red;
          .successcolor: green;
          .tooltip 
            position: relative;
            display: inline-block;
            padding-right: 5px;
            font-size: 20px;
          
          .tooltip .tooltiptext 
              visibility: hidden;
              width: 240px;
              background-color: red;
              color: white;
              text-align: center;
              border-radius: 6px;
              padding: 5px 0;
              font-size: 15px;
              /* Position the tooltip */
              position: absolute;
              z-index: 1;
              top: -5px;
              left: 105%;
          

          .tooltip:hover .tooltiptext 
              visibility: visible;
          
          bluecolor: darkblue; background-color: darkblue;

    </style>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="https://fonts.googleapis.com/css?family=Raleway:400,700,800" rel="stylesheet">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--vuejs-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
</head>

<body>
    <div id="app">
 <nav class="navbar navbar-fixed-top">
    <div class="container">
     <div class="navbar-header">
       <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
         <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">My Site</a>
        </div><!--end .navbar-header-->
        <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
            <li v-show="admin==1"><a href="adminMenu.php">Admin</a></li>
            <li><a href="#">Subscriptions</a></li>
            <li><a href="#">Templates</a></li>
            <li><a href="#">Stock</a></li>
            <li v-show="sesloggedin==0"><a href="#" data-toggle="modal" data-target="#loginModal">Login</a></li>
            <li v-show="sesloggedin==1"><a href="logout.php">Logout</a></li>
            <li><a href="#">Signup</a></li>
            </ul>
        </div><!--end #navbar-->
     </div><!--end container-->
    </nav>
     <div class="container">
      <div id="loginModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
            <!--modal header-->
                <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">X</button>
                <h2 class="modal-title">Login</h2>
                </div>
                <!--modal body-->
                <div class="modal-body">
                <form role="form">
                    <div class="form-group">
                        <label for="username">Username/Email</label>
                        <input v-on:click="error=0; loginsub=0;" v-model="userName" type="text" class="form-control" placeholder="Username/Email" id="username" name="userName">
                        <a href="#">Forgot Username</a>
                    </div>
                    <div class="form-group">
                        <label for="password">Password</label>
                    <input v-on:click="error=0; loginsub=0;" v-model="password" type="password" class="form-control" placeholder="Password" name="password" id="password">
                        <a href="#">Forgot Password</a>
                    </div>
                    <div v-show="error==1 || userName.length<=7 && loginsub==1 || password.length<=7 && loginsub==1"><small class="error">Username/Email or password was incorrect...Try again</small>
                    </div>
                    </form>
                </div>
                <!--modal footer-->
                <div class="modal-footer">
                <button v-on:click="submit();" class="btn btn-primary btn-block">Login</button>
                </div>
            </div>
            </div>
        </div>
        </div>
    </div>
        <script>
  var app = new Vue(
    el: '#app',
    data: 
      userName: '',
      password: '',
      success: '<?php echo $success;?>',
      error: '',
      showPopUp: '',
      loginsub: '',
      response: [],
      sesusername: '<?php if (isset($_SESSION['username'])) echo $_SESSION['username'];?>',
      sesemail: '<?php if (isset($_SESSION['email']))  echo $_SESSION['email'];?>',
      sesloggedin: '<?php if (isset($_SESSION['loggedin'])) echo $_SESSION['loggedin'];?>',
      sesfirstname: '<?php if (isset($_SESSION['firstname'])) echo $_SESSION['firstname'];?>',
      seslastname: '<?php if (isset($_SESSION['lastname'])) echo $_SESSION['lastname'];?>',
      sesphone: '<?php if (isset($_SESSION['phonenumber'])) echo $_SESSION['phonenumber'];?>',
      sescompanyname: '<?php  if (isset($_SESSION['companyname'])) echo $_SESSION['companyname'];?>',
      admin: '<?php if (isset($_SESSION['admin'])) echo $_SESSION['admin'];?>'
    ,
    created: function() 
      this.showPopUp = "<?php if(isset($_GET['showLoginForm']) and $_GET['showLoginForm']==1)echo true; elseecho false;?>";
      this.loginsub = 0;
    ,
    methods: 
      popUp: function() 
        this.showPopUp = !this.showPopUp;
      ,
      submit: function() 
        this.loginsub = 1
        if (this.userName.length >= 8 && this.password.length >= 8) 
          var jsonString = JSON.stringify(
            userName: this.userName,
            password: this.password
          );
          $.ajax(
            url: "login.php",
            method: "POST",
            dataType: "JSON",
            data: jsonString,
            success: function(data) 
              var vueapp = this;
              vueapp.response = data;
              vueapp.error = data.error;
              if(data.showPopUp==false)
                  $('#loginModal').modal('hide');
              
              if (data.success == 1) 
                window.location = window.location.href.split("?")[0];
              
              console.log(data);
            .bind(this)
          );
        
      
    
  );
</script>

【问题讨论】:

你在使用 vue 开发工具吗? 是的,我正在使用 vue 开发工具 看这段代码好像根本不需要Vuejs。 是的,我做 v-on:click="submit();"我想用vuejs可以吗? 希望奥基夫先生永远不会注册.. 【参考方案1】:

为了使 vue 开发工具正常工作,页面上应该至少有一个 Vue 实例。

因为您的数据存在转义问题。你的 Vue 实例永远不会被创建

转换自

 sesusername: '<?php if (isset($_SESSION['username'])) echo $_SESSION['username'];?>',

 sesusername: '<?php if (isset($_SESSION["username"])) echo $_SESSION["username"];?>',

【讨论】:

以上是关于未检测到 Vuejs的主要内容,如果未能解决你的问题,请参考以下文章

vuejs 计算数据检测模型是不是已更新

vuejs 应用程序中无法检测到的内存泄漏

VueJS 异步检测语言与 Yandex Translate API

Vue js [Vue 警告]:检测到重复键:

vuejs中数组更新检测的问题

vuejs中数组更新检测的问题