簡體   English   中英

Vue.JS 2.5.1:未捕獲的語法錯誤:意外的令牌導出

[英]Vue.JS 2.5.1 : Uncaught SyntaxError: Unexpected token export

我試圖使用 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>

未捕獲的語法錯誤:意外的令牌導出

我很確定 Export 上的代碼有錯誤,但我已經檢查了很多次,但似乎無法在語法中找到錯誤。

我還是 Javascript、Vue.JS 和 Bootstrap Vue 的新手,所以任何幫助都會很有用,謝謝! 無論如何,這段代碼來自 Bootstrap Vue 的文檔

如果你打算使用 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>

'#app'是將這些部分聯系在一起的東西,而不是導入/導出

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM