I'm learning Vue and would like to use vue-tabs.
The instructions for "installing" it globally are:
//in your app.js or similar file
// import Vue from 'vue'; // Already available
import VueTabs from 'vue-nav-tabs';
Vue.component('tabs', Tabs);
Vue.component('tab', Tab);
However, Chrome 66 doesn't like the import
statement. VueTabs
is defined as a top-level var
in vue-tabs.js
:
import VueTabs
Uncaught SyntaxError: Unexpected identifier
Some of the above might be incorrect. I'm still muddling my way through the basics of modern web development. So I'd appreciate a little higher-level description of whether I can do this or why not. It seems all the documents I find assume familiarity with pre-compilation and build steps.
I'd like to avoid using npm
, webpack
or yarn
, etc, for the time being in order to focus on Vue
. I like that Vue
can be used by simply downloading vue.js
into a local directory and then making it available using only a <script>
tag.
I've tried using <script https://...vue-tabs.js>
but haven't had any luck as with Vue
.
Is it possible to use vue-tabs
the same way, or is some kind of pre-compilation or build step going to be required?
It should be simple for you. If you don't want to use bundler like Webpack, then your HTML would be something like:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div id="app">
<vue-tabs>
<v-tab title="First tab">
First tab content
</v-tab>
<v-tab title="Second tab">
Second tab content
</v-tab>
<v-tab title="Third tab">
Third tab content
</v-tab>
</vue-tabs>
</div>
<!-- Load Vue.JS -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<!-- Load Vue-Tabs -->
<script src="https://unpkg.com/[email protected]/dist/vue-tabs.js"></script>
<!-- YOUR APPLICATION JS FILE -->
<script type="text/javascript">
new Vue({
el: "#app"
});
</script>
</body>
</html>
Also, you won't have to do any plugin installation or component registration as you are using it without ES modules or bundler. VueTabs
will automatically install the plugin and register components when running as an old-school script.