From 4f1a38ad34118cc89516f9f8d9d00ff8e98d79bf Mon Sep 17 00:00:00 2001
From: wanggang <76527413@qq.com>
Date: Tue, 31 Dec 2019 10:07:28 +0800
Subject: [PATCH] Vue.component ajax load template
Former-commit-id: fc6759db9f05a9f14c5996a9090636fd9c1e0f99
---
projects/IoTCenter/wwwroot/test.c1.html | 1 +
projects/IoTCenter/wwwroot/test.c1.js | 36 ++++++++++++++++++-------
projects/IoTCenter/wwwroot/test.html | 21 +++------------
3 files changed, 31 insertions(+), 27 deletions(-)
create mode 100644 projects/IoTCenter/wwwroot/test.c1.html
diff --git a/projects/IoTCenter/wwwroot/test.c1.html b/projects/IoTCenter/wwwroot/test.c1.html
new file mode 100644
index 00000000..0c9a3548
--- /dev/null
+++ b/projects/IoTCenter/wwwroot/test.c1.html
@@ -0,0 +1 @@
+
foo {{count}}
\ No newline at end of file
diff --git a/projects/IoTCenter/wwwroot/test.c1.js b/projects/IoTCenter/wwwroot/test.c1.js
index 0ef34b35..e00e0b95 100644
--- a/projects/IoTCenter/wwwroot/test.c1.js
+++ b/projects/IoTCenter/wwwroot/test.c1.js
@@ -1,11 +1,27 @@
-const Foo = Vue.component('page-about', {
- template: 'foo {{count}}
',
- data() {
- return {
- count: 123
- };
- },
- created: function () {
- alert('created');
- }
+//const Foo = Vue.component('fool', {
+// template: 'foo {{count}}
',
+// data() {
+// return {
+// count: 123
+// };
+// },
+// created: function () {
+// alert('created');
+// }
+//});
+const Foo = Vue.component('fool', function (resolve, reject) {
+ // 可以请求一个html文件,既然存放模板还是html文件存放比较好
+ $.get("./test.c1.html").then(function (res) {
+ resolve({
+ template: res,
+ data() {
+ return {
+ count: 123
+ };
+ },
+ created: function () {
+ alert('created');
+ }
+ })
+ });
});
diff --git a/projects/IoTCenter/wwwroot/test.html b/projects/IoTCenter/wwwroot/test.html
index e32da79c..5f87eb3b 100644
--- a/projects/IoTCenter/wwwroot/test.html
+++ b/projects/IoTCenter/wwwroot/test.html
@@ -18,35 +18,22 @@
-
-
+
+
+
-