|
123 | 123 | `;
|
124 | 124 |
|
125 | 125 | const exampleJS = `
|
126 |
| -{ |
127 |
| - data: { |
128 |
| - progress: Math.random() * 100 |
129 |
| - }, |
130 |
| - methods: { |
131 |
| - clicked() { |
132 |
| - this.progress = Math.round(Math.random()*10000)/100; |
133 |
| - console.log("Change progress to " + this.progress); |
134 |
| - } |
| 126 | +data: { |
| 127 | + progress: Math.random() * 100 |
| 128 | +}, |
| 129 | +methods: { |
| 130 | + clicked() { |
| 131 | + this.progress = Math.round(Math.random()*10000)/100; |
| 132 | + console.log("Change progress to " + this.progress); |
135 | 133 | }
|
136 |
| -}`; |
| 134 | +} |
| 135 | +`; |
137 | 136 |
|
138 | 137 | export default {
|
139 | 138 | components: {layout},
|
|
178 | 177 |
|
179 | 178 | console.warn = function (text) {
|
180 | 179 | self.log('warning', text);
|
181 |
| - self.originalWarn.apply(console, arguments); |
182 | 180 | };
|
183 | 181 |
|
184 | 182 | console.log = function (text) {
|
185 | 183 | self.log('info', text);
|
186 |
| - self.originalLog.apply(console, arguments); |
187 | 184 | };
|
188 | 185 |
|
189 | 186 | console.error = function (text) {
|
190 | 187 | self.log('danger', text);
|
191 |
| - self.originalError.apply(console, arguments); |
192 | 188 | };
|
193 | 189 | }
|
194 | 190 | },
|
|
210 | 206 | ];
|
211 | 207 | },
|
212 | 208 | js_fiddle() {
|
213 |
| - // Inject options |
214 |
| - let js = this.js.trim(); |
215 |
| - js = `{el:'#app',\r\n` + js.substring(1); |
216 |
| - return `new Vue(${js})`.trim(); |
| 209 | + let js = `new Vue({el:'#app',\r\n${this.js.trim()}})`.trim(); |
| 210 | + return `window.onload = function() {${js}}`; |
217 | 211 | },
|
218 | 212 | html_fiddle() {
|
219 |
| - return ` |
220 |
| -<div id='app'> |
221 |
| - ${this.html} |
222 |
| -</div>`.trim(); |
| 213 | + return `<div id='app'>\r\n${this.html}\r\n</div>`.trim(); |
223 | 214 | },
|
224 | 215 | lazy_run() {
|
225 | 216 | if (!this.lazy_run_) {
|
|
280 | 271 | let options;
|
281 | 272 | try {
|
282 | 273 | /* eslint-disable no-eval */
|
283 |
| - eval('options=' + this.js); |
| 274 | + eval('options={' + this.js + '}'); |
284 | 275 | } catch (err) {
|
285 | 276 | throw new Error(`Compiling JS: ${err}`);
|
286 | 277 | }
|
|
0 commit comments