最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Syntax Error: let is disallowed as a lexically bound name - Stack Overflow

programmeradmin2浏览0评论

I am using vue.js and getting this error "Uncaught SyntaxError: let is disallowed as a lexically bound name". When I debug it shows a blank screen and this error in the console.

I have Googled but nothing helpful was found.

Here is my Vue code:

    let Task = {
      props: ['task'],
      template: `
       <div>
        <div class="tasks">
          {{ task.body }}

        </div>
       </div>
    `

    },

     let Tasks = {
       components:{
         'task': Task
       },

       data: {
         return {
           tasks: [
            {id: 1, body: 'Task One', done: false }
           ],
         }
       },

       template: `
        <div>
       <task></task>
           <form action="">
             form
           </form>
      </div>
      `
     },

      let app = new Vue({
        el:'#app',
        components: {
         'tasks': Tasks
         'task': Task
       }
     })

I am using vue.js and getting this error "Uncaught SyntaxError: let is disallowed as a lexically bound name". When I debug it shows a blank screen and this error in the console.

I have Googled but nothing helpful was found.

Here is my Vue code:

    let Task = {
      props: ['task'],
      template: `
       <div>
        <div class="tasks">
          {{ task.body }}

        </div>
       </div>
    `

    },

     let Tasks = {
       components:{
         'task': Task
       },

       data: {
         return {
           tasks: [
            {id: 1, body: 'Task One', done: false }
           ],
         }
       },

       template: `
        <div>
       <task></task>
           <form action="">
             form
           </form>
      </div>
      `
     },

      let app = new Vue({
        el:'#app',
        components: {
         'tasks': Tasks
         'task': Task
       }
     })
Share Improve this question asked Oct 23, 2017 at 17:58 horcrux88horcrux88 3313 gold badges6 silver badges15 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 17

If you are separating your declarations with commas, you should not repeat let. either remove let from each declaration, or use semi-colons instead.

Example:

let a = {}, b = 5, c = function(){}; // OK
let a = {}; let b = 5; // OK
let a = {}, let b = 5; //Not OK -- error
let Task = {
  props: ['task'],
  template: `
   <div>
    <div class="tasks">
      {{ task.body }}

    </div>
   </div>
`

};

 let Tasks = {
   components:{
     'task': Task
   },

   data: {
     return {
       tasks: [
        {id: 1, body: 'Task One', done: false }
       ],
     }
   },

   template: `
    <div>
   <task></task>
       <form action="">
         form
       </form>
  </div>
  `
 };

  let app = new Vue({
    el:'#app',
    components: {
     'tasks': Tasks
     'task': Task
   }
 })

You wrote some commas that should have been semicolons

发布评论

评论列表(0)

  1. 暂无评论