Vue.component("preview-field", { template: '#preview-single-field-template', props: [ 'label', 'value', 'dataType', 'format', ], mounted: function() { }, destroyed: function() { }, data: function() { return { item: {} }; }, methods: { getValue: function() { // Return the value formatted. if (this.format == "url") { return "" + this.value + ""; } if (this.format == "multi-line") { return this.replaceLineBreaks(this.value); } return this.value; }, replaceLineBreaks: function(value) { if (!value) { // Null or undefined or bad input } var output = ""; // Replace line-breaks with "\n" //output = value.replace(/(?:\r\n|\r|\n)/g, '\\n'); output = value.replace(/(?:\r\n|\r|\n)/g, '
'); return output; } } });