Code Monkey home page Code Monkey logo

Comments (4)

tserkov avatar tserkov commented on May 30, 2024

I've added your feature suggestion, please let me know if it suits your needs!

from vue-plugin-load-script.

3blake7 avatar 3blake7 commented on May 30, 2024

I couldnt get it to work, maybe my setup is different.

router.js

export default new Router({
	mode: 'history',
	base: process.env.BASE_URL,
	routes: [
		{
			path: '/',
			name: 'home',
			component: () => import(/* webpackChunkName: "home" */ './views/Home.vue')
		},
		{
			path: '/login',
			name: 'login',
			component: () => import(/* webpackChunkName: "login" */ './views/Login.vue')
		},

views/Login.vue

<template>
	<div>
		<DisplayAlert />
		<LoginForm />
	</div>
</template>

<script>
	import DisplayAlert from '../components/DisplayAlert'
	import LoginForm from '../components/LoginForm'
	
	export default {
		components: {
			DisplayAlert,
			LoginForm
		}
	}
</script>

components/LoginForm.vue

		mounted () {
		
			this.$loadScript("https://www.google.com/recaptcha/api.js?render=6LeTonoUAAAAAF5EJSdJ80adJI0-oYFgTR9_tUlS")
			
			.then(() => {
			
				grecaptcha.ready();
				
			})
			.catch(() => {
			
				console.log('recaptcha failed to load');
				
			});

		},
		unmounted () {
		
			this.$unloadScript("https://www.google.com/recaptcha/api.js?render=6LeTonoUAAAAAF5EJSdJ80adJI0-oYFgTR9_tUlS")
		
		}

my menu is in app.js

<v-btn flat to="/login"><v-btn flat to="/login">

according to vuetify, to= uses vue-router

i found another plugin called script2 which claimed to do do per component loading and unloading but i couldnt get it to work. i guess i might have it setup wrong

from vue-plugin-load-script.

tserkov avatar tserkov commented on May 30, 2024

There is no unmounted lifecycle hook in Vue -- I think you're looking for destroyed

from vue-plugin-load-script.

3blake7 avatar 3blake7 commented on May 30, 2024

i actually tried beforeDestroy and destroyed first, that didn't work. i think i figured it out, your module and probably script2 was successfully removing the .js but the google recaptcha badge was still present because the javascript injected an i frame. i wasnt sure the js was being removed because webpack chops up all the js.

document.getElementsByClassName('grecaptcha-badge')[0].remove();

thanks for your help!

from vue-plugin-load-script.

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.