undefined是啥意思?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了undefined是啥意思?相关的知识,希望对你有一定的参考价值。
参考技术A不少的朋友在浏览计算机专业论坛过程中,经常会发现undefined这个词组,究竟undefined代表着什么意思,它都有什么作用,下面让我们一起去了解吧。
简要回答
undefined是个计算机程序语句,一般使用于指示变量尚未赋值。用于指示变量尚未用单等号进行赋值。
详细内容
undefined表示“未定义”,一个特殊值,通常用于指示变量尚未赋值。对未定义值的引用返回特殊值“未定义”。类型定义代码 typeof(undefined) 返回未定义字符串。当将“未定义”转换为字符串时,它转换为空字符串。
“未定义”值与特殊值null(空)相似。事实上,当使用相等运算符对null(空)和“未定义”进行比较时,它们的比较结果为相等。
null的类型是一个对象,用来表示一个变量没有任何数值,而undefined是指变量没有定义任何值。
undefined与null不同,它表示无值的意思,并且具有独一无二的类型,它区别任何对象、数组、数值、字符串和布尔型。alert(typeof(undefined))的返回值为undefined。
未定义数据类型的值也只有一个。那就是Undefined。因此也被称为Undefined型。它主要用于尚未分配值的变量。使用未定义型变量可以检查自己是否已经定义某个变量。
<!-- ngView : undefined --> 是啥意思
【中文标题】<!-- ngView : undefined --> 是啥意思【英文标题】:what does <!-- ngView : undefined --> mean<!-- ngView : undefined --> 是什么意思 【发布时间】:2014-01-11 01:22:25 【问题描述】:我得到一个这样的 dom:
<div class="row">
<::before>
<div class="col-lg-12">
<!-- ngView: undefined -->
<ng-view class="ng-scope">
<h1 class="ng-scope">Hello world</h1>
</ng-view>
</div>
<::after>
</div>
做什么:
<!-- ngView: undefined -->
是什么意思?
一切似乎都很好,但我不喜欢这个评论,因为似乎有些东西不能正常工作?
模板如下所示:
<h1>Hello world</h1>
它是这样配置的:
var myApp = angular.module('myApp', [
'ngRoute',
.....
]);
myApp.config(['$routeProvider', function($routeProvider)
$routeProvider.when('/my_template', templateUrl: '/web-angular/my_template.html')
.when( ..... );
]);
【问题讨论】:
【参考方案1】:将您的“ng-view”指令放在 div 或 span 中。比如……
<div ng-view></div>
<span ng-view></span>
在这里查看 IE 限制AngularJS IE Guide 并查看数字 3 和 4。由此,我认为这只是一个警告。像它一样引起你和我的注意的东西。请注意,在您的课程中声明 ng-view 仍然有效,但您会在标记中收到相同的警告消息。
【讨论】:
【参考方案2】:对于遇到此问题并且对其他答案没有任何运气的其他人,我遇到了这个问题,因为我没有将控制器作为模块的依赖项。
angular.module('myApp', ['module-for-missing-page'])
包含此依赖项可以正确加载视图。
【讨论】:
【参考方案3】:在锚标签中注入你的视图。像这样
<div>
<a href="#/home"> Home</a>
<a href ="#/students"> Students </a>
<a href="#/courses"> Courses </a>
<ng-view> </ng-view>
</div>
var app = angular.module("MyApp", ["ngRoute"])
.config(function ($routeProvider)
$routeProvider
.when("/home",
templateUrl: "Templates/home.html",
controller: "homeController"
)
.when("/courses",
templateUrl: "Templates/courses.html",
controller: "courseController"
)
.when("/students",
templateUrl: "Templates/students.html",
controller: "studentsController"
)
)
.controller("homeController", function ($scope)
$scope.message = "I am in home controller";
)
.controller("courseController",function($scope)
$scope.message = "I am in courses controller";
)
.controller("studentsController", function ($scope)
$scope.message = "I am in students controller";
)
并检查您是否放置了正确的 ng-route 链接。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-route.min.js">
</script>
【讨论】:
以上是关于undefined是啥意思?的主要内容,如果未能解决你的问题,请参考以下文章