I am using Vue js and python flask as my backend. I want to have some local variable set. How can it be done?

后端 未结 2 429
别那么骄傲
别那么骄傲 2021-01-26 02:39

My Vue js file. Here I am using two urls from localhost. I want to make a configuration file such that if I make changes in config file, I will be able to get the same changes.<

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 03:14

    As I mentioned in comment - you can create some external object, something like this, let's call it config.js

    export default {
    
        config: {
          url: 'myurl'
        }   
    
    }
    

    Then import it in your component file

    import ConfigFile from '../config'
    

    Then in your data you can use it like this

    data() {
      return {
       url: ConfigFile.config.url
      }
    }
    

    And then you can use url it in your template.

    {{ url }}

提交回复
热议问题