【问题标题】:Why my UI Grid cannot load the grid为什么我的 UI Grid 无法加载网格
【发布时间】:2017-07-08 18:18:03
【问题描述】:

Here is my runnable plunker

我按照UI Grid official tutorial 中的教程进行操作。 我不知道为什么我无法加载网格。我没有发现任何语法错误。

这是来自控制台的部分错误:

访问过的网址 / editor-1.2.0.js:2 访问的 URL /?p=catalogue emmet.js 加载资源失败:服务器响应状态为404(未找到) editor-1.2.0.js:7 AUTH 对象 editor-1.2.0.js:2 事件跟踪 Plunk Beautify Toolbar undefined undefined editor-1.2.0.js:2 事件跟踪 Plunk 保存工具栏 undefined undefined editor-1.2.0.js:2 访问的 URL /oXEt5IfdrpkkPSxysncy?p=catalogue editor-1.2.0.js:2 事件跟踪多面板显示预览工具栏 undefined undefined editor-1.2.0.js:2 访问的 URL /oXEt5IfdrpkkPSxysncy?p=preview run.plnkr.co/:1 混合内容:“https://plnkr.co/edit/oXEt5IfdrpkkPSxysncy?p=preview”处的页面是通过 HTTPS 加载的,但请求了不安全的脚本“http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js”。此请求已被阻止;内容必须通过 HTTPS 提供。

<!DOCTYPE html>
<html ng-app="app">

<head>
    <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
    <script src="http://ui-grid.info/release/ui-grid.js"></script>
</head>

<body>
    <h1>Hello Plunker!</h1>

    <div ng-controller="MainCtrl">
        <div ui-grid="{ data: myData }" class="myGrid"></div>
    </div>

    <script>
        var app = angular.module('app', ['ui.grid']);
        app.controller('MainCtrl', ['$scope', function($scope) {
            $scope.myData = [{
                    "firstName": "Cox",
                    "lastName": "Carney",
                    "company": "Enoromo",
                    "employed": true
                }, {
                    "firstName": "Lorraine",
                    "lastName": "Wise",
                    "company": "Comveyer",
                    "employed": false
                }, {
                    "firstName": "Nancy",
                    "lastName": "Waters",
                    "company": "Fuelton",
                    "employed": false
                }
            ];
        }])
    </script>

    <style>
        .myGrid {
            width: 500 px;
            height: 250 px;
        }
    </style>
</body>

</html>

【问题讨论】:

    标签: angularjs angular-ui-grid ui-grid


    【解决方案1】:

    您的 ui-grid 的 cdn 不正确。你所有的 src 都应该指向一个安全的 url,即使用 https。原因是您试图从安全站点访问不安全的脚本。这将被阻止,因为内容只能通过 HTTPS 提供。

      <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.6/ui-grid.css" type="text/css">
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.6/ui-grid.min.js"></script>
      </head>
    

    工作Plunkrhttps://plnkr.co/edit/I87wgFzlqmtl6dcPem6F?p=preview

    【讨论】:

    • 但是,你可以看看这个官方plunker,他们没有使用https等plnkr.co/edit/?p=preview
    • plnkr.co/edit/?p=catalogue。再次检查官方 plunker,当您添加流行的包时,它指向 https 而不是不安全的 http 服务器。
    • 如果你说的是script.js和style.css,那是因为它的文件夹结构和plunkr一样,所以不需要使用https,直接引用即可。
    • 但是你可以在这个页面“ui-grid.info/docs/#/tutorial/101_intro”中点击“在 Plunkr 中编辑”。您可以签入那个 plunkr,它没有使用任何 https,而是 http。但他们正在工作。我只是想知道为什么他们可以通过使用 https 来工作,但我不能通过使用他们的脚本和样式来工作?
    • 非常感谢您的帮助。您在聊天中向我提供了非常详细的为什么我的 plunkr 不起作用。如果连接安全站点,我不知道我需要连接到安全 CDN。希望这个链接能帮助未来和我有同样问题的开发者:developer.mozilla.org/en-US/docs/Web/Security/Mixed_content/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多