Skip to main content
updated docs link
Source Link
tony19
  • 140k
  • 23
  • 281
  • 354

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "MyFunction" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Propertieshttps://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "MyFunction" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "MyFunction" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

deleted 3 characters in body
Source Link
user10493964
user10493964

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "changeFavicon""MyFunction" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "changeFavicon" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "MyFunction" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??

Source Link
user10493964
user10493964

How to import a external function in a Vue component?

I'm a newbie in javascript and vue.js and I'm facing somme issue when trying to add a new function in an existing programme.

I have put my new function (with others) in a separate file:

export const MyFunctions = {
MyFunction: function(param) {
    // Doing stuff
}
}

Then I import the file in the component file and calling my function :

<script>
    import {MyFunctions} from "@/components/MyFunctions.js";
    export default {
        name:"Miniature",
        computed: {
            useMyFunction() {
                MyFunction("Please do some stuff !");
            }
        }
    }
</script>

When the component is used, I get an error message

[Vue warn]: Property or method "changeFavicon" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

I've read a lot of documentation and fail to understand why it doesn't work. Can anyone help me with this ??