更改路线时外部JavaScript停止工作(Vue JS)

时间:2019-06-27 15:48:51

标签: vue.js vue-router

我是vue js的初学者。我目前在更改路线时遇到外部javascipt停止的问题。

例如,当我从/(根目录)开始,然后单击/ shop,然后单击/(根目录)时,外部javascript停止运行(例如,幻灯片放映停止)。

我尝试使用名为vue-plugin-load-script的插件。为了在main.js中动态加载外部javascript,但结果仍然相同,更改路线时外部javascript将停止工作。

外部javascript位于index.html

index.html


<html>

<body>

...

</body>

<script src="<%= BASE_URL %>js/plugins.js"></script>

</html>

route.js


{

path: '/',

name: 'home',

component: Home

},

{

path: '/shop',

name: 'shop',

component: Shop

},

App.vue


<template>

<div id="app">

<router-view />

</div>

</template>

外部javascript是全局提供的,因此可以使用每个页面。我可以使用不同的路径运行相同的外部javascript吗?

1 个答案:

答案 0 :(得分:0)

尝试更改现实的import sbt.Keys._ import sbt.{util, _} val scioVersion = "0.7.4" val beamVersion = "2.11.0" val scalaMacrosVersion = "2.1.1" //logLevel := util.Level.Debug lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq( organization := "haaretz", // Semantic versioning http://semver.org/ version := "0.1.0-SNAPSHOT", scalaVersion := "2.12.8", scalacOptions ++= Seq("-target:jvm-1.8", "-deprecation", "-feature", "-unchecked"), javacOptions ++= Seq("-source", "1.8", "-target", "1.8") ) lazy val paradiseDependency = "org.scalamacros" % "paradise" % scalaMacrosVersion cross CrossVersion.full lazy val macroSettings = Seq( libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, addCompilerPlugin(paradiseDependency) ) lazy val root: Project = project .in(file(".")) .settings(commonSettings) .settings(macroSettings) .settings( name := "htz-dataflow", description := "DataFlow pipelines for htz projects", publish / skip := true, libraryDependencies ++= Seq( "com.spotify" %% "scio-core" % scioVersion, "com.spotify" %% "scio-bigquery" % scioVersion, "com.spotify" %% "scio-test" % scioVersion % Test, "org.apache.beam" % "beam-runners-direct-java" % beamVersion, "org.apache.beam" % "beam-runners-google-cloud-dataflow-java" % beamVersion, "org.slf4j" % "slf4j-simple" % "1.7.25", "org.jsoup" % "jsoup" % "1.11.3", "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.8", "com.typesafe.slick" %% "slick" % "3.3.1", "org.slf4j" % "slf4j-nop" % "1.7.26", ) ) .enablePlugins(PackPlugin) lazy val repl: Project = project .in(file(".repl")) .settings(commonSettings) .settings(macroSettings) .settings( name := "repl", description := "Scio REPL for POC", libraryDependencies ++= Seq( "com.spotify" %% "scio-repl" % scioVersion ), Compile / mainClass := Some("com.spotify.scio.repl.ScioShell"), publish / skip := true ) .dependsOn(root) 而不是<%= BASE_URL %>/js/plugins.js的路线