I have product listing page based on category.When i click enter first time in prodcut page after click category it call api.But after changing category url is changed but new template is not render.
ie,
if i click Drinks category (http://localhost:8080/#/categories/drinks) it shows items in drinks.After change Drink to starter (http://localhost:8080/#/categories/starter) url was changed but still drinks data shown.(new api call does not run).
<div class="swiper-slide w-auto p-2" v-for="(category,index) in categories" :key="index">
<router-link :to="{ name: 'categoriesItems.slug', params: { slug: category.slug }}"
class="icons icon-60 shadow-sm"
:class="slug == category.slug ? 'badge-warning' : ''"
>
<i class="material-icons text-default">{{category.icon_name}}</i>
</router-link>
<p class="small mt-2 text-mute">{{category.name}}</p>
</div>
index.js
{
path: '/categories/:slug',
name: 'categoriesItems.slug',
component: categoryItems
},
package.json
{
"name": "app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"#popperjs/core": "^2.9.3",
"#vue-stripe/vue-stripe": "^4.2.5",
"axios": "^0.21.1",
"bootstrap": "^5.1.0",
"core-js": "^3.6.5",
"jquery": "^3.6.0",
"moment": "^2.29.1",
"popper.js": "^1.16.1",
"swiper": "^5.4.5",
"vue": "^2.6.11",
"vue-awesome-swiper": "^4.1.1",
"vue-axios": "^3.2.5",
"vue-bootstrap-sidebar": "^1.0.9",
"vue-infinite-scroll": "^2.0.2",
"vue-loading-button": "^0.2.0",
"vue-loading-overlay": "^3.0.1",
"vue-moment": "^4.1.0",
"vue-router": "^3.2.0",
"vue-simple-alert": "^1.1.1",
"vue-stripe-checkout": "^3.5.15",
"vue-toastify": "^1.8.0",
"vue2-swiper": "0.0.13",
"vue2-timepicker": "^1.1.6",
"vuejs-dialog": "^1.4.2",
"vuelidate": "^0.7.6",
"vuex": "^3.4.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
app.vue
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#import './assets/vendor/elegant_font/HTMLCSS/style.css';
#import './assets/vendor/materializeicon/material-icons.css';
#import './assets/vendor/swiper/css/swiper.min.css';
#import './assets/css/style.css';
</style>
Related
Project was setup using Ionic's CLI, nothing custom, except some linter configs.
The problem: every time i try to use IonMenu, it just breaks the whole page.
Page Component:
<template>
<ion-page>
<ion-menu
side="start"
content-id="menuContent"
>
<ion-header>
<ion-toolbar color="secondary">
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-label>START MENU CONTENTS</ion-label>
</ion-content>
</ion-menu>
<ion-router-outlet id="menuContent" />
</ion-page>
</template>
<script>
import {
IonPage,
IonRouterOutlet,
IonContent,
IonHeader,
IonMenu,
IonTitle,
IonToolbar
} from '#ionic/vue';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'index-page',
components: {
IonPage,
IonRouterOutlet,
IonContent,
IonHeader,
IonMenu,
IonTitle,
IonToolbar
}
});
</script>
Result (it's identical in browser and in emulator): nested menu content renders, but the page looks like this
If I remove <ion-menu> component, everything works just fine
My package.json
{
"name": "notes",
"version": "0.0.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint:eslint": "./node_modules/.bin/eslint -c .eslintrc.js .",
"lint:eslint:fix": "npm run lint:eslint -- --fix",
"lint:stylelint": "./node_modules/.bin/stylelint --config stylelint.config.js .",
"lint:stylelint:fix": "npm run lint:stylelint -- --fix"
},
"dependencies": {
"#capacitor/app": "1.1.1",
"#capacitor/core": "3.5.1",
"#capacitor/haptics": "1.1.4",
"#capacitor/keyboard": "1.2.2",
"#capacitor/status-bar": "1.0.8",
"#ionic/vue": "6.0.0",
"#ionic/vue-router": "6.0.0",
"core-js": "3.6.5",
"vue": "3.2.21",
"vue-router": "4.0.12"
},
"devDependencies": {
"#capacitor/cli": "3.5.1",
"#types/jest": "27.0.2",
"#typescript-eslint/eslint-plugin": "5.6.0",
"#typescript-eslint/parser": "5.6.0",
"#vue/cli-plugin-babel": "~5.0.0-rc.1",
"#vue/cli-plugin-e2e-cypress": "~5.0.0-rc.1",
"#vue/cli-plugin-eslint": "~5.0.0-rc.1",
"#vue/cli-plugin-router": "~5.0.0-rc.1",
"#vue/cli-plugin-typescript": "~5.0.0-rc.1",
"#vue/cli-plugin-unit-jest": "~5.0.0-rc.1",
"#vue/cli-service": "~5.0.0-rc.1",
"#vue/eslint-config-typescript": "9.1.0",
"#vue/test-utils": "2.0.0-rc.16",
"#vue/vue3-jest": "27.0.0-alpha.3",
"#vuebits/bem": "1.2.2",
"babel-jest": "27.3.1",
"cypress": "8.7.0",
"eslint": "8.4.1",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-unused-imports": "2.0.0",
"eslint-plugin-vue": "8.2.0",
"jest": "27.3.1",
"npm-run-all": "4.1.5",
"sass": "1.52.2",
"sass-loader": "13.0.0",
"stylelint": "13.13.1",
"stylelint-config-rational-order": "0.1.2",
"stylelint-config-standard": "22.0.0",
"stylelint-order": "4.1.0",
"stylelint-webpack-plugin": "2.1.1",
"ts-jest": "27.0.7",
"typescript": "4.3.5",
"vue-auto-routing": "1.0.1",
"vue-eslint-parser": "9.0.2"
},
"description": "An Ionic project"
}
My vue.config.js
const VueAutoRoutingPlugin = require('vue-auto-routing/lib/webpack-plugin');
const { definePlugin } = require('./config/webpack/define-plugin');
const { linterPlugins } = require('./config/webpack/linter-plugins');
const { getWebpackAliases } = require('./config/webpack/aliases');
module.exports = {
configureWebpack: config => {
config.stats = 'normal';
const routerPlugin = new VueAutoRoutingPlugin({
pages: 'src/pages',
importPrefix: '~/src/pages/'
});
config.plugins = config.plugins.concat([definePlugin, routerPlugin]);
if (process.env.LINT_ON_BUILD === 'true') {
plugins.push(...linterPlugins);
}
config.resolve.alias = { ...config.resolve.alias, ...getWebpackAliases() };
}
};
I'm using VueJs with these dependences:
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"bootstrap": "v4.5.3",
"bootstrap-vue": "^2.21.2",
"core-js": "^3.3.2",
"vue": "^2.6.0",
"vue-resource": "^1.5.3",
"vue-router": "^3.1.3",
"vue-sweetalert2": "^5.0.2",
"vue-uuid": "^2.0.2",
"vuex": "^3.6.2"
},
"devDependencies": {
"#vue/cli-plugin-eslint": "^4.0.0",
"#vue/cli-service": "^4.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"sass": "^1.19.0",
"sass-loader": "^8.0.0"
}
}
And I have a nav bar:
<b-nav-item :to="{name: 'client'}">Client</b-nav-item>
<b-nav-item :to="{name: 'company'}">Company</b-nav-item>
<b-nav-item :to="{name: 'employee'}">Employee</b-nav-item>
<b-nav-item :to="{name: 'product'}">Product</b-nav-item>
<b-nav-item :to="{name: 'provider'}">Provider</b-nav-item>
<b-nav-item-dropdown text="Transaction" right>
<b-dropdown-item href="client">Account</b-dropdown-item>
<b-dropdown-item href="#">Settings</b-dropdown-item>
</b-nav-item-dropdown>
</b-navbar-nav>
I wish to remove this error that I have on the browser:
[vue-router] <router-link>'s tag prop is deprecated and has been removed in Vue Router 4. Use the v-slot API to remove this warning: https://next.router.vuejs.org/guide/migration/#removal-of-event-and-tag-props-in-router-link.
but I have not found a good solution in order to pass with the router and without to re-loading all the web site like with href.
I have also to use <router-link> but it doesn't work.
i am wrighting test cases for LoginNew.vue component , when i am trying to import that component inside the spec.js file i am getting shallowMount error [check my error here] ,i don't know why i am getting this error please help me to fix this issue
jest.config.js
module.exports = {
moduleNameMapper:{
"~(.*)$": "<rootDir>/resources/js/$1",
},
setupFilesAfterEnv: ['<rootDir>resources/src/tests/setup.js'],
resolver: require.resolve(`jest-pnp-resolver`),
testEnvironment: `node`,
};
LoginNew.vue
<template>
<div>
<h1 id="title">Login</h1>
<input type="text" id="input-username"/>
<input type="password" id="input-password"/>
<button id="btn-sign-in">Sign In</button>
</div>
</template>
<script>
export default {
name: 'LoginNew'
}
</script>
Login.spec.js
import LoginNew from '../../src/Pages/LoginNew.vue';
import{shallowMount} from '#vue/test-utils';
describe('LoginNew.vue',()=>{
describe('When Loaded',()=>{
it('has the required elements',()=>{
const wrapper =shallowMount(LoginNew);
expect(wrapper.find('#input-username').exists()).toBe(false);
expect(wrapper.find('#input-password').exists()).toBe(false);
});
});
});
package.json
{
"name": "vue-fundoo",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 3000",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test": "jest"
},
"dependencies": {
"#vue/composition-api": "^1.0.0-rc.9",
"#vuelidate/core": "^2.0.0-alpha.18",
"#vuelidate/validators": "^2.0.0-alpha.15",
"axios": "^0.21.1",
"bootstrap": "^5.0.1",
"core-js": "^3.6.5",
"dotenv": "^10.0.0",
"jquery": "^3.6.0",
"vue": "^2.6.11",
"vue-axios": "^3.2.4",
"vue-router": "^3.5.1",
"vue-template-compiler": "^2.6.12",
"vuelidate": "^0.7.6"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/test-utils": "^1.2.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.2",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"jest": "^27.0.3",
"node-sass": "^5.0.0",
"sass": "^1.19.0",
"sass-loader": "^10.1.1",
"vue-jest": "^3.0.7",
"vue-test-utils": "^1.0.0-beta.11",
"webpack": "^4.0.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"jest": {
"transform": {
"^.+\\.vue$": "vue-jest",
"^.+\\.js$": "babel-jest"
}
}
}
Update the jest configuration to
testEnvironment: 'jsdom'
The defaults has been changed for Jest 27
Read more about it here.
https://jestjs.io/blog/2021/05/25/jest-27
When including a Sass file (in node_modules) in my Vue component <style> tag, the file is located, but any relative modules to that file are not. Everything seems configured correctly, but I'm obviously missing something. What gives?
I've tried installing/uninstalling various Webpack loaders (including css-loader), deleted and reinstalled node_modules, tried various PostCSS configurations, but nothing has made any progress so far.
Thanks in advance.
Vue component (IconicIcon.vue):
<template>
<div>
<span class="oi oi-icon-name" :title="icon" aria-hidden="true"></span>
</div>
</template>
<script>
export default {
name: "iconic-icon",
props: {
icon: String
}
};
</script>
<style scoped lang="scss">
$icon-font-path: "~open-iconic/font/css/fonts";
#import "~open-iconic/font/css/open-iconic-bootstrap.scss";
</style>
open-iconic-bootstrap.scss:
/* Bootstrap */
/* Override Bootstrap default variable */
$icon-font-path: '../fonts/' !default;
#font-face {
font-family: 'Icons';
src: url('#{$icon-font-path}open-iconic.eot');
src: url('#{$icon-font-path}open-iconic.eot?#iconic-sm') format('embedded-opentype'), url('#{$icon-font-path}open-iconic.woff') format('woff'), url('#{$icon-font-path}open-iconic.ttf') format('truetype'), url('#{$icon-font-path}open-iconic.svg#iconic-sm') format('svg');
font-weight: normal;
font-style: normal;
}
... (snip)
relevant file structure:
root/
src/
components/
IconicIcon.vue
node_modules/
open-iconic/
font/
css/
open-iconic-bootstrap.scss
fonts/
open-iconic.eot
open-iconic.otf
open-iconic.svg
open-iconic.ttf
open-iconic.woff
error:
WAIT Compiling... 8:37:49 PM
98% after emitting CopyPlugin
ERROR Failed to compile with 4 errors 8:37:50 PM
These relative modules were not found:
* ../fonts/open-iconic.eot in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePost
Loader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules
/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/IconicIcon.vue?vue&type=style&
index=0&id=468ee29c&scoped=true&lang=scss&
* ../fonts/open-iconic.svg in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePost
Loader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules
/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/IconicIcon.vue?vue&type=style&
index=0&id=468ee29c&scoped=true&lang=scss&
* ../fonts/open-iconic.ttf in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePost
Loader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules
/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/IconicIcon.vue?vue&type=style&
index=0&id=468ee29c&scoped=true&lang=scss&
* ../fonts/open-iconic.woff in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePos
tLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_module
s/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/IconicIcon.vue?vue&type=style
&index=0&id=468ee29c&scoped=true&lang=scss&
package.json:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "concurrently -r -k -n doc,nod,vue -c magenta,green,cyan \"docker-compose up\" \"nodemon server/app.js\" \"vue-cli-service serve\"",
"build": "vue-cli-service build",
"start": "node server/app.js",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e"
},
"dependencies": {
"apollo-server": "^2.9.15",
"babel-loader": "^8.0.6",
"bootstrap": "^4.4.1",
"core-js": "^3.4.3",
"eslint": "^6.8.0",
"graphql": "^14.5.8",
"graphql-type-json": "^0.2.1",
"jquery": "^3.4.1",
"js-yaml-loader": "^1.2.2",
"leaflet": "^1.6.0",
"lowdb": "^1.0.0",
"mkdirp": "^0.5.1",
"mongodb": "^3.4.1",
"open-iconic": "^1.1.1",
"popper.js": "^1.16.0",
"shortid": "^2.2.8",
"slugify": "^1.3.6",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.1.0",
"#vue/cli-plugin-e2e-cypress": "^4.1.0",
"#vue/cli-plugin-router": "^4.1.0",
"#vue/cli-plugin-unit-jest": "^4.1.0",
"#vue/cli-plugin-vuex": "^4.1.0",
"#vue/cli-service": "^4.1.0",
"#vue/test-utils": "1.0.0-beta.29",
"concurrently": "^5.0.2",
"graphql-tag": "^2.9.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
},
"browserslist": [
"> 1%",
"last 2 versions"
],
"jest": {
"preset": "#vue/cli-plugin-unit-jest"
}
}
I solved this by just using the CSS, instead of the Sass. Seems like a copout, but I've spent too much time on this already.
<template>
<div>
<span class="oi" :title="icon" aria-hidden="true" :class="`oi-${icon}`"></span>
</div>
</template>
<script>
export default {
name: "iconic-icon",
props: {
icon: String
}
};
</script>
<style scoped lang="scss">
#import "~open-iconic/font/css/open-iconic-bootstrap.css";
</style>
This kind of issues could be related to the way that the saas loader works.
I've encountered the same problem in one of my projects and resolved it by moving the font directory to the assets folder.
If you google for this you will find that other found the same solution as I am posting here.
In your case you should change the $icon-font-path variable to the following:
$icon-font-path: '/assets/fonts/' !default;
It will work!
I have the following main.js:
import Test from './components/Test.vue'
Vue.component('test', Test);
var vm = new Vue({
el: '.vue-wrap',
components: { Test },
});
window.vm = vm;
And I have the folllowing Test.vue:
<template>
<li>
Hello World
</li>
</template>
<script>
export default {
name: 'Test',
}
</script>
I build the application and I copy the content of "dist" folder in my website's "vue" folder. I have the following HTML file:
<!DOCTYPE html><html><head><meta charset=utf-8><link rel=apple-touch-icon sizes=76x76 href=static/img/apple-icon.png><link rel=icon type=image/png sizes=96x96 href=static/img/favicon.png><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><title>My App!</title><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link type=text/css href="https://fonts.googleapis.com/css?family=Muli:400,300" rel=stylesheet><link type=text/css href="https://fonts.googleapis.com/css?family=Montserrat" rel=stylesheet><link type=text/css href=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css rel=stylesheet><link type=text/css href=https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css rel=stylesheet><link href=static/css/themify-icons.css rel=stylesheet><link href=/vue/static/css/app.d9b210b92ea60ad0856c8dc063cccfec.css rel=stylesheet></head><body><div class=wrapper id=app></div><script type=text/javascript src=/vue/static/js/manifest.bdf9878acc459aaa413c.js></script><script type=text/javascript src=/vue/static/js/vendor.0eae82ab4e0e2a32fd9c.js></script><script type=text/javascript src=/vue/static/js/app.aa1500d2bdd1b2f93122.js></script>
<div class="vue-wrap">
<test></test>
</div>
</body>
</html>
My package.json file:
{
"name": "vue-paper-dashboard-pro",
"version": "1.1.0",
"description": "A premium Vue.js admin dashboard for bootstrap. Coded by Cristi Jora, designed by Creative Tim.",
"author": "cristian.jora <cristian.jora#corebuild.eu>",
"private": true,
"scripts": {
"dev": "cross-env ENABLE_ESLINT=false node build/dev-server.js",
"build": "cross-env ENABLE_ESLINT=false node build/build.js",
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"unit:watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --watch",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e"
},
"dependencies": {
"axios": "^0.18.0",
"chartist": "^0.11.0",
"easy-pie-chart": "^2.1.7",
"element-ui": "^2.0.3",
"fullcalendar": "^3.6.2",
"google-maps": "^3.2.1",
"jquery": "^3.2.1",
"jvectormap-next": "^3.0.0",
"jwt-decode": "^2.2.0",
"perfect-scrollbar": "0.7.1",
"postcss-import": "^11.1.0",
"postcss-url": "^7.3.2",
"router": "^1.3.2",
"sweetalert2": "^6.11.4",
"vee-validate": "^2.0.0-rc.21",
"vue": "^2.5.2",
"vue-axios": "^2.1.1",
"vue-beautify": "^1.1.3",
"vue-clickaway": "^2.1.0",
"vue-form-wizard": "^0.7.0",
"vue-google-autocomplete": "^1.1.0",
"vue-nav-tabs": "^0.5.4",
"vue-notifyjs": "^0.2.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-component": "^0.9.1",
"babel-plugin-istanbul": "^4.1.5",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^4.1.2",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"compression-webpack-plugin": "^1.0.1",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.1.0",
"cross-env": "^5.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^3.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-node": "^4.2.3",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.5.0",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"friendly-errors-webpack-plugin": "^1.1.3",
"function-bind": "^1.1.0",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"inject-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"lolex": "^1.5.2",
"marked": "^0.3.6",
"mocha": "^3.2.0",
"nightwatch": "^0.9.12",
"node-sass": "^4.5.3",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"raw-loader": "^0.5.1",
"sass-loader": "^5.0.1",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0",
"url-loader": "^0.5.8",
"vue-loader": "^13.0.4",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"vue-test-utils": "^1.0.0-beta.3",
"webpack": "^2.7.0",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.18.0",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
}
}
Shouldn't VueJs populate the "test" tag directly with HTML? Because in my case all css/js files are loaded ok, if I enter "vm" in console I can see the Vue object, but still, the template part is not inserted in HTML. How can I do that? My page is empty. I want to load multiple components and they should be inserted in the component slots if these are found in HTML.
If you are using it as the root component, you can just directly use that component using render()
import Test from './components/Test.vue'
var vm = new Vue({
el: '.vue-wrap',
render: h => h(Test)
});
Can you try to add template part:
var vm = new Vue({
el: '.vue-wrap',
components: { Test },
template: '<Test/>
});
If you'd want to be able to specify components Vue is using by wrapping it in the "main" <div class="vue-wrap"> you can make use of slots.
var vm = new Vue({
el: '.vue-wrap',
template: "<slot></slot>",
components: {
/* all components injected by "slots" */
Test,
SomeComponent
},
});
... then you can inject your <test></test> component by adding it as a child of a main div.
<div class="vue-wrap">
<test></test>
<some-component></some-component>
</div>
Otherwise, if you're able to write your template inside Vue components, you should use template key/option as suggested by #latovic.
var vm = new Vue({
el: '.vue-wrap',
template: `
<test></test>
<some-component></some-component>
`,
components: { Test, SomeComponent }
});
If you're building your application, in other words, if you can use .vue files, then you can write template inside your single-file components.
UPDATE (DUE TO QUESTION UPDATES)
In your particular example, try removing Vue.component('test', Tree); asi it may cause some problems because of case in-sensitive names (this way you're creating global component test and you already imported and registered component Test).
Also, as mentioned before, if you want to pass <test></test> to your HTML and not a template, you'd need a <slot></slot>.
import Test from "/path/to/component";
var vm = new Vue({
el: '.vue-wrap',
template: "<slot></slot>",
components: {
/* all components injected by "slots" */
Test
},
});
But if your index.html is completely empty, it's an issue with your build process, which we cannot help with, as we have no information about it.