4

I am writing one single page of my website in Vue.js. I have a file.html and a file.js. file.html looks like this:

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script> 
<body>
   <div id="app"> 
    // everything to be displayed on the page (data, v-if & v-else tags etc.)
   </div>
</body>

while file.js looks like this:

new Vue({
    el: '#app',
    data: {
        msg: "hello",
        // some other data
    }
});

When I load the website, a warning shows:

[email protected]:440 [Vue warn]: It seems you are using the standalone build of Vue.js in an environment with Content Security Policy that prohibits unsafe-eval. The template compiler cannot work in this environment. Consider relaxing the policy to allow unsafe-eval or pre-compiling your templates into render functions.

I have to disallow eval in my application, so the only way is to precompile the vue codes. I have looked up on Webpack and Browserify, but they seems quite complex and always used with one whole application, while I just want to precompile one single file.

Is there any way to do it? Thanks in advance.

1 Answer 1

2

No, there is no way to do that as far as I know. To pre-compile templates you must use single files components (or jsx).

Here is I think a comprehensive list of your alternatives:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.