欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

分享angular bootstrap timepicker TypeError提示该如何解决

程序员文章站 2022-05-11 09:03:49
...
这篇文章主要介绍了angular bootstrap timepicker TypeError提示的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

angular bootstrap timepicker TypeError: Cannot set property '$render' of undefined,如何解决?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css" rel="external nofollow" >
  <link rel="stylesheet" href="node_modules/angular-bootstrap-datetimepicker/src/css/datetimepicker.css" rel="external nofollow" />
</head>
<body ng-app="MyApp">
<p>{{mode}}</p>
  <datetimepicker data-ng-model="mode"></datetimepicker>
</body>
  <script type="text/javascript" src="node_modules/moment/moment.js"></script>
  <script type="text/javascript" src="node_modules/angular/angular.js"></script>
  <script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.js"></script>
  <script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.templates.js"></script>
  <script type="text/javascript" src="locales/bootstrap-datetimepicker.zh-CN.js"></script>
  <script>
  var myAppModule = angular.module('MyApp', ['ui.bootstrap.datetimepicker'])
  </script>
</html>

package.json

{
 "name": "cynthia",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
 },
 "author": "",
 "license": "ISC",
 "dependencies": {
  "angular-bootstrap-datetimepicker": "^1.1.4",
  "bootstrap": "^3.3.7"
 }
}

把以上两个文件放到同一目录

npm install

运行index.html文件就可以看到效果了。

如果出现:TypeError: Cannot set property '$render' of undefined

说明angular的版本太低,这个版本要求至少在v1.2.30以上.

以上就是分享angular bootstrap timepicker TypeError提示该如何解决的详细内容,更多请关注其它相关文章!