This code displays the non-breaking space escape sequence instead of the actual spaces:
<html>
<head>
<script src="../js/jquery.min.js"></script>
<script src="../js/knockout-2.2.1.js"></script>
<script>
$(document).ready(function() {
var modelType = function() {
this.A = ko.observable('a b c');
};
var model = new modelType();
ko.applyBindings(model);
});
</script>
</head>
<body>
<p data-bind="text: A"></p>
</body>
</html>
It displays the following:
a b c
instead of
a b c
How do I prevent this behavior?
您应该使用html
绑定而不是text
:
<p data-bind="html: A"></p>
您可以使用html绑定http://knockoutjs.com/documentation/html-binding.html :
<p data-bind="html: A"></p>
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.