简体   繁体   English

nuxt build打破了VueJS事件

[英]nuxt build Breaks VueJS Events

I'm running a nuxtjs application in production and it's causing some VueJS functionality to break, particular with DOM events. 我正在生产中运行nuxtjs应用程序,它导致某些VueJS功能中断,尤其是DOM事件。 However , development mode works just fine as it should flawlessly, though it is slower than production mode due to the code not being minified and compiled and all that. 但是 ,开发模式可以正常工作,因为它没有缺陷,但由于未缩减代码和编译的速度,因此它比生产模式要慢。

  • @click events do not fire their functionality @click事件不会触发其功能
  • .prevent does not prevent anything .prevent不会阻止任何事情

Here's my source of an example section that does not work. 这是无法正常工作的示例部分的源。

The @click event calls that change the view do not do anything. 更改view@click事件调用不会执行任何操作。

Upon hitting enter to fire v-on:keydown.enter="login" it does not get prevented and the form gets submitted as a GET request to the same page ( the URL shows the GET ?variables ) v-on:keydown.enter="login" Enter键触发v-on:keydown.enter="login"它不会被阻止,并且该表单将作为GET请求提交到同一页面(URL显示GET ?variables)

After looking at the HTML code in the browser to see if there's any logged warnings or errors, there's nothing and nothing on the server side logs. 在浏览器中查看HTML代码以查看是否记录了任何警告或错误之后,服务器端日志上什么也没有。

Plus, the <button> tags that have the @click to fire the login or signup methods do not have any events on them, basically not doing anything; 另外,具有@click来触发登录或注册方法的<button>标记上没有任何事件,基本上什么也没做。 just HTML. 只是HTML。

On my production server after running nuxt build by executing npm run build , there are no errors or warnings . 在我的生产服务器上,通过执行npm run build运行nuxt build之后, 没有错误或警告

<template>
<div class='card'>
    <div class='tabs 2-col'>
        <span :class="{active : view != 'signup'}" @click="view = 'login'">
            Login
        </span>
        <span :class="{active : view == 'signup'}" @click="view = 'signup'">
            Sign Up
        </span>
    </div>
    <div class='card-body'>
        <form v-show="view == 'login'" v-on:keydown.enter="login" novalidate>
            <!-- my other html -->
            <button @click.prevent="login">Login</button>
        </form>
        <form v-show="view == 'signup'" v-on:keydown.enter="signup" novalidate>
            <!-- my other html -->
            <button @click.prevent="signup">Sign Up</button>
        </form>
    </div>
</div>
</template>
<script>
export default {
    data : function(){
        return { view : 'login'};
    },
    methods : {
        login: function(){
            // my functionality
        },
        signup:function(){
            // my functionality
        },
    }
}
</script>

Thank you for any help! 感谢您的任何帮助! I've been banging my head for hours. 我已经好几个钟头了。

data proprerty should be a function that return the object. data属性应该是返回对象的函数。 try to do this: 尝试这样做:

data: function () {
  return {
    view: 'login',
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM