简体   繁体   English

有什么方法可以检查.vue 文件模板的语法错误吗?

[英]Is there any way to check for syntax error for .vue file's template?

Quite embarrassingly, I made a mistake in a template section of the vue file.比较尴尬的是,我在vue文件的一个模板部分搞错了。 I wrote v-for as following.我写了 v-for 如下。

<template>
    <ul v-for="{data, key} in json_data" :key="key">
        <!-- some list related -->
    </ul>
</template>

Basically I used curly braces instead of paranthesis.基本上我使用花括号而不是括号。

However, as a novice javascript / vue.js / nuxt.js developer, I did not catch this for a long time.但是,作为一个新手 javascript / vue.js / nuxt.js 开发人员,我很长时间没有注意到这一点。 For the longest time, I thought I was doing something wrong in the script section of the code.很长一段时间,我以为我在代码的脚本部分做错了什么。 I was wondering why data and key were returning undefined.我想知道为什么datakey返回未定义。

As I code more and more, those silly syntax error may go away.随着我编码的越来越多,那些愚蠢的语法错误可能会 go 消失。 But is there any training wheel that can be used to catch those error?但是有没有任何训练轮可以用来捕捉这些错误?

i assume that you are using vue.js in production mode.我假设您在生产模式下使用 vue.js。 you should use the vue.js library in developer's mode during development, this mode will display for you in the console a lot of details about your exceptions and errors.在开发过程中,您应该在开发人员模式下使用 vue.js 库,此模式将在控制台中为您显示许多有关您的异常和错误的详细信息。

here is the cdn:这是cdn:

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> 

i also suggest that you use vue.js developer tools extension on your browser here is the link for this extension我还建议您在浏览器上使用 vue.js 开发人员工具扩展这是此扩展的链接

https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd

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

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