Reputation: 24061
I'm trying to include an external script depending on a var:
<div v-if="shouldInclude">
<script src="/my-script.js"></script>
</div>
Yet according to the network panel, the script is loaded when shouldInclude
is both true and false.
Where am I going wrong?
Upvotes: 0
Views: 1021
Reputation: 3918
You may need to use require
instead, and place it inside a lifecycle hook.
created: function () {
if (this.shouldInclude) {
require('./my-script.js');
}
}
Upvotes: 1