Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.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 对象没有方法设置jwplayer_Javascript_Html_Pug_Jwplayer - Fatal编程技术网

Javascript 对象没有方法设置jwplayer

Javascript 对象没有方法设置jwplayer,javascript,html,pug,jwplayer,Javascript,Html,Pug,Jwplayer,我从jade调用这个javascript文件 -if ... -else div#container script(type='text/javascript') jwplayer('container').setup({ file: '/path/to/file.m3u8', width: '0', height: '0' }); 未捕获的TypeError:对象#没有方法“设置” 头文件中也有相同的javascript

我从jade调用这个javascript文件

-if ...

-else
  div#container
  script(type='text/javascript')
    jwplayer('container').setup({       

     file: '/path/to/file.m3u8',
     width: '0',
     height: '0'
    });
未捕获的TypeError:对象#没有方法“设置”


头文件中也有相同的javascript文件。

您需要将pug置于纯文本模式,并在脚本标记末尾加一个句点,否则它将尝试在其下面呈现更多DOM元素。脚本在帕格中不是一个保留字,它只是像其他HTML元素一样呈现它,帕格不知道下面是JavaScript(这在我看来是件好事)

将句点添加到标记的末尾会告诉帕格它应该将标记中包含的所有内容呈现为纯文本。如果要在纯文本部分中使用pug变量,则需要使用

这将对您有用:

  script.
    jwplayer('container').setup({       

     file: '/path/to/file.m3u8',
     width: '0',
     height: '0'
    });

另外,您不需要在脚本元素()上再添加type属性。

您确定元素的
id
是由div\container完成的吗