我如何将c#代码转换为javascript以完成相同的操作。
var s = styles.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
If styles
is a string, it's as simple as:
styles.split(/[\r|\r\n]/);
var styles = 'body {font-size: 12px;}\\n\\ .someClass {color: red}'; document.querySelector('#result').textContent = '[' + (styles.split(/[\\r|\\r\\n]/)) +']';
<pre id="result"></pre>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.