Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 错误类型错误:无法读取属性';标记名';使用Typedjs时的空值_Javascript_Html_Angular_Typedjs - Fatal编程技术网

Javascript 错误类型错误:无法读取属性';标记名';使用Typedjs时的空值

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

我会使用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 * 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