Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

vue使用渲染函数onClick不工作。

【已解决】看英文文档吧。没问题。中文的更新不及时

在线演示
https://codesandbox.io/s/autu...

使用官方文档的这种方式,没效果。。

app.component("input-component", {
  methods: {
    doThisInCapturingMode($event) { console.log("clicked"); },
    doThisOnce($event) { console.log(`keypressed ${$event.keyCode}`); },
    doThisOnceInCapturingMode() { console.log("mousehover"); },
  },
  render() {
    return Vue.h("div", [
      // Vue.h("h1", { onClick: ($event) => console.log("clicked", $event.target) }, "test"),
      Vue.h("input", { placeholder: "working", onClick: ($event) => console.log("clicked", $event.target) }),
      Vue.h("input", {
        placeholder: "not work",
        onClick: {
          handler: this.doThisInCapturingMode,
          capture: true,
        },
        onKeyUp: {
          handler: this.doThisOnce,
          once: true,
        },
        onMouseOver: {
          handler: this.doThisOnceInCapturingMode,
          once: true,
          capture: true,
        },
      }),
    ]);
  },
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
(function anonymous(
) {
with(this){return _c('input',{on:{"click":abc}})}
})

可以通过 compile 来查看
Vue.compile('<input @click="abc" />').render.toString()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...