小编Jay*_*Jay的帖子

使用angular.js路线手动刷新时仍然会"找不到"

在Angular.js路由上阅读了大量的报告和stackoverflow问题之后,当我进行手动刷新时,我仍然收到"未找到"错误.

脚步:

  1. 浏览到localhost- >因为我的配置(下面),我被带到了localhost/home.视图和一切都很好.
  2. 在浏览器中点击刷新 - >浏览器显示此信息 Not Found: the requested /home is not found on this server

这个问题可能最像刷新页面给出"找不到页面"

我的配置

// Routing configuration.
angular.module('myModule')
    .config(['$routeProvider', '$locationProvider', 
    function ($routeProvider, $locationProvider) {
        // Enable pushState in routes.
        $locationProvider.html5Mode(true);

        $routeProvider
            .when('/home', {
                templates: {
                    layout: '/views/home.html'
                },
                title: 'Welcome!'

            })
            .when('/launchpad', {
                templates: {
                    layout: '/views/layouts/default.html',
                    content: '/views/partials/profile.html'
                },
                title: "Launchpad"
            })
            .otherwise({
                redirectTo: '/home'
            });

    }
]);
Run Code Online (Sandbox Code Playgroud)

我做过的其他事情:

  • 在我index.html,我已经有了<base href="/">
  • 升级到角度1.2.1

这是我尝试过的htaccess规则.没有工作.

刷新页面给出"找不到页面" …

javascript .htaccess angularjs angular-routing

10
推荐指数
2
解决办法
1万
查看次数

将 &lt;svelte:window&gt; 绑定到 `onbeforeunload`

我本来希望绑定<svelte:window>但没有运气。

<!-- doesn't work -->
<svelte:window on:beforeunload={() => true} />

<!-- doesn't work -->
<svelte:window on:onbeforeunload={() => true} />

<!-- doesn't work -->
<svelte:window on:beforeUnload={() => true} />

Run Code Online (Sandbox Code Playgroud)

在所有情况下,window.onbeforeunload都是null

我最终只是继续,window.onbeforeunload = () => true但想知道为什么元素上的设置不起作用。

svelte svelte-3

5
推荐指数
1
解决办法
3771
查看次数