Javascript 错误类型错误:无法读取属性';标记名';使用Typedjs时的空值
我会使用TypedJS库 我已经使用npm install typed.js安装了它 然后将typed.js文件包含在.angular-cli.json中Javascript 错误类型错误:无法读取属性';标记名';使用Typedjs时的空值,javascript,html,angular,typedjs,Javascript,Html,Angular,Typedjs,我会使用TypedJS库 我已经使用npm install typed.js安装了它 然后将typed.js文件包含在.angular-cli.json中 "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/typed.js/lib/typed.js" ], 在我的组件中: import { Component, OnInit } from '@angular/core'; import
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/typed.js/lib/typed.js"
],
在我的组件中:
import { Component, OnInit } from '@angular/core';
import * as Typed from 'typed.js';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.component.html',
styleUrls: ['./a-propos.component.css']
})
export class AProposComponent implements OnInit {
constructor() { }
ngOnInit() {
var typed2 = new Typed('#typed', {
strings: ["<b>#Font End ?</b>", "<b>#Front End ?</b>", "<b>#Back End ?</b>", "<b> #Fullstack ?</b>", "<b>ça m'interesse !</b>"],
typeSpeed: 30,
backDelay: 2000,
loop: true,
});
}
}
类型库希望选择器是标记名,而不是我认为的id。尝试将“标记名”添加到html,但不起作用您不需要将标记名添加到html,因为它已经是标记名了。在您的情况下,标记名应为“p”
<p id="typed"> </p>
ERROR TypeError: Cannot read property 'tagName' of null