账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    beego框架中使用vue的component 编译出错
    27
    0

    这样一个网页

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="js/vue.js"></script>
    </head>
    
    <body>
    <div id="example-2">
        <simple-counter></simple-counter>
        <simple-counter></simple-counter>
        <simple-counter></simple-counter>
    </div>
    
    <script>
        var data = { counter: 0 }
    
        Vue.component('simple-counter', {
            template: '<button v-on:click="counter += 1">{{ counter }}</button>',
            // 技术上 data 的确是一个函数了,因此 Vue 不会警告,
            // 但是我们却给每个组件实例返回了同一个对象的引用
            data: function () {
                return data
            }
        });
    
        new Vue({
            el: '#example-2'
        })
    </script>
    </body>
    </html>

    router中

    
    func init() {
        beego.Router("/arcTest.html", &controllers.ArcTestController{}, "*:Arc")
    }
    

    controller中

    func (c *ArcTestController) Arc() {
        c.TplName = "arcTest.html"
    }

    单独运行html页面没有任何问题
    放进beego框架中
    bee run一下报错
    [E] [template.go:174] parse template err: arcTest.html template: arcTest.html:20: function "counter" no
    t defined
    [W] [beego.go:97] template: arcTest.html:20: function "counter" not defined
    panic: template: arcTest.html:20: function "counter" not defined

    counter不能使用,删去就编译成功了,但是明明有定义 这个例子就是在vue官网上复制的,为什么beego就是编译不过,导致整个项目都运行不起来,有没有大神知道怎么解决,跪求。

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部