-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue 2.0 Problem with Slot #3965
Comments
There's a bug in the browserify template that I just today submitted a PR for, and I assume it's the reason for your problem. It will likely be fixed tomorrow. Meanwhile, the fix for you is easy - your package.json should look like this: // ...
"browserify": {
"transform": [
"babelify",
"aliasify",
"vueify"
]
},
"aliasify": {
"aliases": {
"vue$": "vue/dist/vue"
}
},
//... Then you can use the original |
Hello , I tried to change the package.json but when i use import Vue from 'vue' i have a error
When use import Vue from 'vue/dist/vue' no render content inside slot |
please provide a live reproduction (repository) or ask on the forums for help. forum , Stack Overflow or on gitter |
here repository with the problem |
If i use npm run build instead of nrpm run dev. This work fine. |
Got it, @eugenio4。 I'll take a look at this issue, @LinusBorg |
Please just don't mix runtime only build with standalone build. They are incompatible. My suggestion after digging to the build.js From the comment here
new Vue({
el: '#app',
render: h => h('hello'),
}) For more info, please see https://github.com/vuejs/vue/wiki/Vue-2.0-RC-Starter-Resources#standalone-vs-runtime-builds If you need more complex entry point template, just write an entry component. And render it in render function. More Info: The problem is vue-hot-load api in vueify uses runtime build, and user code uses standalone build. These two builds both mount the same component and are agnostic about each other. The slots children are lost between two conflicting builds. |
As @HerringtonDarkholme metioned, there are two vue versions in your app indeed, standalone and runtime version when you run npm run dev Standalone required from your app.js is used to compile the template in the html, it is resolved to "vue/dist/vue.js" . And in internal there is a runtime version used by vueify to compile your .vue files and hot-reload, it is resolved to "vue/dist/vue.common.js" and bundled to the compiled js files too. It fails when doing some prototype checks in runtime (one from vue.js and the other from vue.common.js), so you just get the default slot node. As for npm run build , NODE_ENV is set to production when you run it, so the hot-reload logic is eliminated and it works. As for your issue, you could just select "Runtime-only" version when init your app with vue-cli, and move all your codes into .vue files. I'll make a PR to update the related docs to specifiy this problem. Maybe the best way is that we could ensure the only one vue version in the browserify template. I am looking into it. |
This problem is explained on the "installation" page of the guide. But maybe it can be improved / also mentioned in the migration guide? |
@LinusBorg I think so. We should also upgrade the browserify template. I'll try to do it. |
Browserify template is also updated, it uses aliasify if standalone was selected. |
@LinusBorg it seems not working as expected, because .vue files are not processed duiring the aliasify transformation. I open a PR here benbria/browserify-transform-tools#26 to add .vue file to its JS_EXTENSIONS. Once it's merged, I will update the template as well. |
@eugenio4 ,this is an issue of browserify template, and I have submited a PR to fix it. I forked your repo and updated it here https://github.com/defcc/vue-slot/blob/master/package.json You could adjust your package.json like this. "browserify": {
"transform": [
"babelify",
"vueify"
]
},
"browser": {
"vue": "vue/dist/vue"
} |
PR merged, I'll close this issue. If your problem still exists, you could report an issue here https://github.com/vuejs-templates/browserify/issues |
Hello, I'm using Vue 2.0 standalone and i have a problem with components with Slot. Always render default value inside slot. Never render content inside custom component
package.json
main.js
Hello.vue
index.html
The text was updated successfully, but these errors were encountered: