Last active
September 17, 2016 16:00
-
-
Save diverted247/9310aa27b0236ab03bbcb9bc547fbe70 to your computer and use it in GitHub Desktop.
Async loading pattern for loading Vue components as modules and wiring via vLoad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//setup component to load async when used | |
//VLoad returns an async function(resolve, reject) {...} | |
//this will | |
Vue.component( 'arrowback' , VLoad( 'component.js' ) ); | |
new Vue({ | |
el: 'body', | |
template:"<arrowback></arrowback>" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["require", "exports"], function (require, exports) { | |
"use strict"; | |
exports.component = { | |
template: "<svg height=\"25px\" width=\"25px\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 8 13\">\n \t<style>.st0{fill:#0000;}</style>\n\t<path class=\"st0\" d=\"M6.4 12.7L.3 6.5 6.4.2l1.3 1.3-4.9 5 4.9 4.9z\"/>\n</svg>", | |
data: function () { | |
return {}; | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export var components = { | |
template: | |
`<svg height="25px" width="25px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 13"> | |
<style>.st0{fill:#0000;}</style> | |
<path class="st0" d="M6.4 12.7L.3 6.5 6.4.2l1.3 1.3-4.9 5 4.9 4.9z"/> | |
</svg>`, | |
data(){ | |
return {}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment