Jér*_*nge 3 html javascript node.js js-beautify
我尝试使用js-beautify了html在node.js应用程序:
var htmlBeautifier = require('js-beautify').html;
...
res = htmlBeautifier.beautify(html);
...
Run Code Online (Sandbox Code Playgroud)
但是我得到:
...
res = htmlBeautifier.beautify(html,{});
^
TypeError: Object function (html_source, options) {
return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
} has no method 'beautify'
Run Code Online (Sandbox Code Playgroud)
有关使用的文档 js-beautify forhtml没有提供太多信息。一个应该是怎样使用js-beautify的html?
根据文档(可能有更多细节),函数html 是函数,而不是将函数作为属性的对象。所以:
var htmlBeautifier = require('js-beautify').html;
//...
res = htmlBeautifier(html);
Run Code Online (Sandbox Code Playgroud)
要么
var htmlBeautifier = require('js-beautify');
//...
res = htmlBeautifier.html(html);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
634 次 |
| 最近记录: |