错误TypeError:无法读取null的属性“loadVideoById”

时间:2017-06-13 12:30:54

标签: angular typescript ionic-framework youtube ionic2

我无法在离子2中播放youtube视频。它显示此错误:

  

TypeError:无法读取null的“loadVideoById”属性

With .Shapes.AddTable(5, 5, 0, 140, 720, 40)                                       
' NumRows / NumColumns / Left / Top / Width / Height
  .Table.ApplyStyle "{5940675A-B579-460E-94D1-54222C63F5DA}"                  
  ' Table Style for No Style, Table Grid
  .Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "Text1"
  .Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = "TeXT2"
  .Table.Cell(1, 3).Shape.TextFrame.TextRange.Text = "Text3"
  .Table.Cell(1, 4).Shape.TextFrame.TextRange.Text = "Text4"
  .Table.Cell(1, 5).Shape.TextFrame.TextRange.Text = "Text5"
  R = 1
  With .Table
    For C = 1 To 5
      .Cell(R, C).Shape.TextFrame.TextRange.Font.Size = 8
      .Cell(R, C).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
      .Cell(R, C).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
    Next
    R = R + 1
  End With

  .Table.Columns(1).Width = 140
  .Table.Columns(2).Width = 60
  .Table.Columns(3).Width = 60
  .Table.Columns(4).Width = 100
  .Table.Columns(5).Width = 360
  .Fill.BackColor.RGB = RGB(255, 255, 255)
  For Each cl In .Table.Rows(1).Cells
    cl.Shape.Fill.BackColor.RGB = RGB(0, 32, 96)
    cl.Shape.Fill.ForeColor.RGB = RGB(0, 32, 96)
    cl.Shape.TextFrame.TextRange.Characters.Font.Bold = True
    cl.Shape.TextFrame.VerticalAnchor = msoAnchorBottom
  Next cl

  ' Adding data to table ------------------------
  R = 2
  With .Table
    While Not rs26.EOF
      For C = 1 To 5
        .Cell(R, C).Shape.TextFrame.TextRange.Text = Nz(rs26.Fields(C - 1)) 
        .Cell(R, C).Shape.TextFrame.TextRange.Font.Size = 8
        .Cell(R, C).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
      Next    'c column
      rs26.MoveNext
      R = R + 1
    Wend
    rs26.Close
  End With

  ' Having trouble getting this part of the code to work ------------------ 
  With .Table
    If .Cell(R, 2).Shape.TextFrame.TextRange.Text = "No" Then
      .Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(255, 0, 0) ' Red
      .Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
    ElseIf .Cell(R, 2).Shape.TextFrame.TextRange.Text = "Yes" Then
      .Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(146, 208, 80)  ' Green
      .Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(146, 208, 80)
    Else
      .Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(166, 166, 166) ' Gray
      .Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(166, 166, 166)
    End If
  End With

End With ' table for chart

当我观察控制台时,我得到了id的值。

请帮忙。

1 个答案:

答案 0 :(得分:1)

我不知道问题是否已经解决,但也许其他人需要答案:)

我遇到了这个问题,在解决之前我看到了你的问题

问题来自HomePage作为您的网站教程

 constructor(public navCtrl: NavController,public player: PlayerService,public youtubeService: YoutubeService,public loadingCtrl:LoadingController) {
    player.setupPlayer();
  }

从构造函数中删除player.setupPlayer();并插入此

 ionViewDidLoad() {
    this.player.setupPlayer();
  }

我希望这会有所帮助