[英]Need help styling on javascript
var stateData = {
MA: { fullName: 'Massachusetts: some infor here | some info here | test'},
VA: { fullName: 'Virginia:' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' },
VA: { fullName: 'Virginia' }
// other states' data...
}
I need help styling the code inside MA, it does not let me put line breaks or anything. 我需要在MA中设置代码样式的帮助,它不允许我将换行符或其他任何内容放入。 Thanks for the help! 谢谢您的帮助!
Sorry, this post is a bit too length for the comment box. 抱歉,此帖子的评论框太长。
\\n
is the universal newline character . \\n
是通用换行符 。
But perhaps you should look at this alternative: 但是也许您应该看看这种选择:
var stateData = {
MA: {
fullName: 'Massachusetts',
motto: 'A catchy expression here',
information: 'More data here',
population: 1000
},
}
To me it looks like you are building some JSON that you'll probably reference like: 对我来说,您似乎正在构建一些可能会引用的JSON,例如:
stateData.MA.fullName
It's considered bad practice to format your raw data. 格式化原始数据被认为是不好的做法。 You should probably do this when you use the data: 使用数据时,您可能应该这样做:
console.log('Now you\'ve travelled to: ' + stateData.MA.fullName + "/n" + stateData.MA.motto);
Just a thought. 只是一个想法。
如果要在JavaScript字符串中换行,则应执行\\ n(代表换行)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.