J
J
Julia2020-12-01 11:18:12
JavaScript
Julia, 2020-12-01 11:18:12

How to make a separate file for settings when building vue cli?

when vue-cli is built, everything is merged into one file.
how to leave one file after assembly so that you can add your own variables to it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Levchenko, 2020-12-02
@taynoeya

I will assume that you have the default build settings using vue-cli, then
put a separate js file in the public/js folder

const MY_APP_CONFIG = {
  setting: 'value',
}
window.MY_APP_CONFIG = MY_APP_CONFIG; // ложим в глобальный объект наши настройки

Files and folders (except index.html) from public will simply be copied to the dist root
Edit public/index.html connect your js script there with settings
Next, in the vue components, you can take data from the global object
<script>
export default {
  data() {
    return {
      config: window.MY_APP_CONFIG,
    };
  },
  created() {
    console.dir(this.config);
  },
}
</script>

A
Alexander Sisyukin, 2016-11-08
@Jony1337

странная регулярка . У вас не заэкранирован символ / в символьном классе. а что искать то она должна ? пока что она только способна доктайп найти...

preg_match('@<meta.*og:image.*?(http:\/\/.*?)"\s+\/>@i',$k, $matches);
$host = $matches[1]; 
echo $host;

результат

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question