Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下 怎么在 内联函数里面 调用 alert 方法? #6

Open
sgf opened this issue Jan 16, 2019 · 2 comments
Open

请教一下 怎么在 内联函数里面 调用 alert 方法? #6

sgf opened this issue Jan 16, 2019 · 2 comments

Comments

@sgf
Copy link

sgf commented Jan 16, 2019

提示报错。

@tangbc
内联代码: <td v-on:click=" if (ok) { alert('11'); } else { alert('22'); }">啊啊啊</td>

Uncaught TypeError: scope.alert is not a function
    at Object.eval (eval at createAnonymous (mvvm.js:1313), <anonymous>:3:52)
    at HTMLTableCellElement.listenerAgent (mvvm.js:1409)

另外我觉得题主这个项目非常厉害。
为什么,因为,其实我是用它来代替 knockout 来用的。我觉得替代或者超越vue几乎很难,但是如果替代或者超越ko却很容易。

另外有没有QQ群 用来交流。。

@tangbc
Copy link
Owner

tangbc commented Jan 16, 2019

这其实是我自己学习 Vue 源码之后自己倒腾的小项目,其实也有一些 bug 的 😂

提示 scope.alert is not a function 是因为在语句解析的时候没有把 window 下的全局方法和常量单独匹配,全当做 data 对象里面的作用域处理了,之后我可以处理下,现在可以先:

model: {
    alert: function (str) {
        alert(str)
    }
}

来代替。

@sgf
Copy link
Author

sgf commented Jan 16, 2019

谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants