Giter VIP home page Giter VIP logo

Comments (10)

im4aLL avatar im4aLL commented on May 22, 2024 3

Still if you are having issue with browserify + vuejs and if

var Vue = require('vue');

new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!'
    }
})

not working then use aliasify

npm install aliasify --save-dev

in package.json

   "aliasify": {
        "aliases": {
            "vue": "vue/dist/vue.js"
        }
    },
    "browserify": {
        "transform": [ "aliasify" ]
    }

then in js file simple call

var Vue = require('vue');

2nd alternative is (without aliasify) -

just use

var Vue = require('vue/dist/vue.js');

it should work!

from vue-resource.

yyx990803 avatar yyx990803 commented on May 22, 2024 1

Here's some info on the plugin interface: http://vuejs.org/guide/extending.html#Extend_with_Plugins

vue-resource auto-installs itself only when it finds a global Vue on window, but in CommonJS there's no global exposed, so you have to manually install it.

from vue-resource.

yyx990803 avatar yyx990803 commented on May 22, 2024

Just require('vue-resource').

But you do need to install it explicitly:

Vue.use(require('vue-resource'))

from vue-resource.

slickorange avatar slickorange commented on May 22, 2024

I am also struggling with this...
I am trying to use a vue-resource.js file I have on disk, like this:

var Vue = require('./vue');
require('./vue-resource');

I have also tried Vue.use(require('vue-resource')) but I can't get it to work...

In the first case I get a post not defined error. In the second case I get Uncaught TypeError: undefined is not a function

from vue-resource.

yyx990803 avatar yyx990803 commented on May 22, 2024

Ahh, I just noticed this package is not on npm. I'll publish it if that's ok with you, @steffans .

@jlem @slickorange in Browserify the require call follows the resolution algorithm of Node modules, so if you clone this repo into ./node_modules of your project, then you should be able to just require('vue-resource').

from vue-resource.

yyx990803 avatar yyx990803 commented on May 22, 2024

Update: it's now on npm. Just npm install vue-resource and you can require('vue-resource') directly.

from vue-resource.

slickorange avatar slickorange commented on May 22, 2024

Still not working...
Here is the code for my main.js file. I am trying to use this in components but I have commented out the components and added a test method that I call by clicking a button.
When clicking the button I still get the post not defined error... I would appreciate any help. I am pretty new to most of this so excuse any stupid errors.

var Vue = require('./vue.js');
require('vue-resource');

new Vue({
    el: '#app',
    components: {
       //searchcard: require('./components/search-card')
        //quoteitems: require('./components/quote-items')
    },

    methods: {
        test: function(){
            console.log('test');
            this.$http.post('/search/',
                {'test' : 'test'})
        }
    }
});

from vue-resource.

yyx990803 avatar yyx990803 commented on May 22, 2024

Ah. When you load it in CommonJS, it doesn't auto-install itself. You need to install it:

var Vue = require('vue')
var Resource = require('vue-resource')

Vue.use(Resource)

from vue-resource.

slickorange avatar slickorange commented on May 22, 2024

Thanks for the insanely quick help :) That did the trick...
Where could I have read up on this to understand it myself? I tried looking through the docs, but I did not see anything.

from vue-resource.

Signorini avatar Signorini commented on May 22, 2024

work, thanks

from vue-resource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.