I'm using browserify with babel as a transform. A special character (Â
) is being added to my own script, as well as other modules in various places. This build/compile is on a Windows machine.
NPM Build Script
browserify -s appClient source/app-client.js -t babelify > build/app-client.js
Input Snippet:
return (
<p>Hello, <span
onClick = { () => setMode('edit') }
style = { styles.displayMode }
>{ word }!
</span>
<input
onKeyUp = { onKeyUp}
placeholder = { word }
ref = 'wordInput'
style = { styles.editMode }
/>
</p>)
}
Output:
Hello, world!
What's odd is that Â
gets generated by
, and not  
. So maybe I'm not looking at the build process.
I can manually edit the JavaScript file to remove the special character.
答案 0 :(得分:3)
在IDE中将受影响文件的编码类型设置为utf-8
。
然后添加......
<meta charset="UTF-8">
...到你的html页面。这应该解决所有错误字符的问题。
注意:如果内容未保存为
meta
,则不需要unicode
标记。它只会使页面将所有内容解释为utf-8
(unicode
)。