passing an array from EJS to Javascript

前端 未结 5 891
隐瞒了意图╮
隐瞒了意图╮ 2021-01-20 23:48

I am trying to passe an array from ejs to JavaScript. I can get to the values inside ejs but not from JavaScript. all the time i get undefined because the contents of the variab

5条回答
  •  -上瘾入骨i
    2021-01-21 00:14

    Use this it will work fine.(Don't use single quotation )

            var test = <%-JSON.stringify(level_tab) %>; 
            console.log("test :"+test);
    

提交回复
热议问题