recherche

Maison  >  Questions et réponses  >  le corps du texte

angulaire.js - Pourquoi Angular-UI-Router ne peut-il pas charger les vues?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

<code><!DOCTYPE html>

<html lang="en" ng-app="app">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    <title>Title</title>

    <script src="node_modules/angular/angular.min.js"></script>

    <script src="node_modules/angular-ui-router/release/angular-ui-router.min.js"></script>

</head>

<body>

<p ui-view></p>

<script>

    var app = angular.module('app', ['ui.router']);

    app.config(function($stateProvider, $urlRouterProvider){

        $urlRouterProvider.otherwise('/a/b');

        $stateProvider

                .state('a', {

                    url: '/a'

                })

                .state('a.b', {

                    url: '/b',

                    template: '<p>This is b</p>'

                })

    });

</script>

</body>

</html></code>

1

<code>为什么我打开页面后,地址是http://localhost:63341/firecontrol/test.html#/a/b,但是没有东西出来呢?template: '<p>This is b</p>'好像没有效果,控制台没报什么错啊?</code>

黄舟黄舟2870 Il y a quelques jours852

répondre à tous(2)je répondrai

  • 大家讲道理

    大家讲道理2017-05-15 17:01:29

    Configuration à l'intérieur d'un

    1

    2

    3

    4

    <code>.state('a', {

        url: '/a',

        template:'<p ui-view></p>'

    })</code>

    répondre
    0
  • 漂亮男人

    漂亮男人2017-05-15 17:01:29

    Vous devez configurer les attributs suivants dans a :

    1

    2

    3

    4

    <code class="js">.state('a', {

        url: '/a',

        abstract: true

    })</code>

    J'espère que cela aide~ :)

    répondre
    0
  • Annulerrépondre