Vue.JS 2.5.1:未捕获的语法错误:意外的令牌导出

2024-06-19

我试图使用 VueJS 和 Bootstrap Vue 制作一个单选按钮,但是当我制作它时发生了这种情况。我预计这是语法错误,就像它所说的那样,但我似乎找不到任何线索。

所以我尝试复制粘贴代码,这是 test_radio.php 的完整代码

<!DOCTYPE html>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
    <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
</head>

<body>
<template>
  <div>
    <b-form-group label="Radios using <code>options</code>">
      <b-form-radio-group id="radios1" v-model="selected" :options="options" name="radioOpenions">
      </b-form-radio-group>
    </b-form-group>

    <b-form-group label="Radios using sub-components">
      <b-form-radio-group id="radios2" v-model="selected" name="radioSubComponent">
        <b-form-radio value="first">Toggle this custom radio</b-form-radio>
        <b-form-radio value="second">Or toggle this other custom radio</b-form-radio>
        <b-form-radio value="third" disabled>This one is Disabled</b-form-radio>
        <b-form-radio :value="{fourth: 4}">This is the 4th radio</b-form-radio>
      </b-form-radio-group>
    </b-form-group>

    <div class="mt-3">
      Selected: <strong>{{ selected }}</strong>
    </div>
  </div>
</template>

    <!-- Vue.js @2.5.1 -->
    <script type="text/javascript" src="js/vue.js"></script>

    <!-- Add this after vue.js -->
    <script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
    <script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

<!-- The error is below -->
<script>
export default {
  data () {
    return {
      selected: 'first',
      options: [
        { text: 'Toggle this custom radio', value: 'first' },
        { text: 'Or toggle this other custom radio', value: 'second' },
        { text: 'This one is Disabled', value: 'third', disabled: true },
        { text: 'This is the 4th radio', value: {fourth: 4} }
      ]
    }
  }
}
</script>
</body>
</html>

未捕获的语法错误:意外的令牌导出 https://i.stack.imgur.com/Che6u.png

我很确定导出的代码有错误,但我已经检查了很多次,但似乎找不到语法错误。

我对 Javascript、Vue.JS 和 Bootstrap Vue 还很陌生,所以任何帮助都会很有用,谢谢!无论如何,这段代码来自 Bootstrap Vue 的文档 https://bootstrap-vue.js.org/docs/components/form-radio.


如果你打算使用 CDN 方法,VueJS 会像这样开始

<!-- Begin of area that is impacted by VueJS -->
<div id="app">
   <b-form-group label="Radios using <code>options</code>">
     <b-form-radio-group id="radios1" v-model="selected" :options="options" name="radioOpenions">
     </b-form-radio-group>
   </b-form-group>
</div>
<!-- End of area that is impacted by VueJS -->


<script>
 var app = new Vue({
   el: '#app',
   data: {
      ...
      }
   })
<script>

The '#app'是将各部分联系在一起的,而不是导入/导出

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Vue.JS 2.5.1:未捕获的语法错误:意外的令牌导出 的相关文章

随机推荐