在组件动作中更改URL

Change URL in component action

本文关键字:URL 组件      更新时间:2023-09-26

当"某些事情"发生时,我需要更改URL。所以我做了一个动作当我调用这个动作时我希望改变发生:

export default Component.extend({
    // ... 
    actions: {
        test: function(){
            this.transitionTo("dashboard");
        }
    },
    testHandle: function()
    {
        this.send("test");
    },
});

我使用ember 1.13。在动作脚本开始后,它向控制台抛出以下内容:

Deprecations were detected, see the Ember Inspector deprecations tab for more details.
Uncaught TypeError: Cannot read property 'enter' of undefined(…)

任何想法?谢谢你。

当然,Ember.Component没有transitionTo方法。你需要从组件发送一个动作,并在控制器中处理它。文档