从 0.7 升级到 0.9:如何访问我的事件的关键路径?

Upgrading from 0.7 to 0.9: how do I access my event's keypath?

https://jsfiddle.net/zFiddler/gm9k4mrc/1/

鉴于此:

var view = new Ractive({
    el : '#container',
    template : "{{#item}}<a href='#' on-click='doSomething'>Do Something</a>{{/}}",
    data : {item : {name: "item"}}
})

view.on('doSomething', event => {
event.original.preventDefault();
console.log(event);
alert(event.keypath);
});

如何访问触发事件的键路径?

在 0.9 中,以 jQuery 风格,并且为了在组件和元素事件之间保持一致,通过 ractive.on will now receive an instance of the Context object as first argument which should contain everything you need to know about the event, the node it's from, the Ractive instance attached to it, and so on. DOM events should be available via the event property of that object (no longer the funny-sounding original). The keypath can be obtained by context.resolve().

附加的处理程序
view.on('doSomething', context => {
  const event = context.event
  event.original.preventDefault();
  console.log(event);
  alert(context.resolve());
});