mirror of
https://github.com/muerwre/muerwre.github.io.git
synced 2025-04-25 02:46:39 +07:00

Author: Fedor Katurov <gotham48@gmail.com> Date: Thu Nov 3 10:38:11 2022 +0600 added whole content
1 line
No EOL
8.6 KiB
JSON
1 line
No EOL
8.6 KiB
JSON
{"_path":"/frontend/vue/adding-global-properties-to-component","_dir":"vue","_draft":false,"_partial":false,"_locale":"en","_empty":false,"title":"Adding Global Properties To Component","description":"The topic's fully covered in the official documentation and in Add global variable to window.","excerpt":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The topic's fully covered in the "},{"type":"element","tag":"a","props":{"href":"https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties","rel":["nofollow"]},"children":[{"type":"text","value":"official documentation"}]},{"type":"text","value":" and in "},{"type":"element","tag":"a","props":{"href":"Add%20global%20variable%20to%20window"},"children":[{"type":"text","value":"Add global variable to window"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For example, you want to add global "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$http"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$translate"}]},{"type":"text","value":" services to all of project's components:"}]},{"type":"element","tag":"code","props":{"code":"// ~/index.d.ts or ~/custom.d.ts\n\nimport axios from 'axios'\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $http: typeof axios\n $translate: (key: string) => string\n }\n}\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// ~/index.d.ts or ~/custom.d.ts\n\nimport axios from 'axios'\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $http: typeof axios\n $translate: (key: string) => string\n }\n}\n"}]}]}]}]},"body":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The topic's fully covered in the "},{"type":"element","tag":"a","props":{"href":"https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties","rel":["nofollow"]},"children":[{"type":"text","value":"official documentation"}]},{"type":"text","value":" and in "},{"type":"element","tag":"a","props":{"href":"Add%20global%20variable%20to%20window"},"children":[{"type":"text","value":"Add global variable to window"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For example, you want to add global "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$http"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$translate"}]},{"type":"text","value":" services to all of project's components:"}]},{"type":"element","tag":"code","props":{"code":"// ~/index.d.ts or ~/custom.d.ts\n\nimport axios from 'axios'\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $http: typeof axios\n $translate: (key: string) => string\n }\n}\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-ba2647"},"children":[{"type":"text","value":"// ~/index.d.ts or ~/custom.d.ts"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-b38898"},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-1ce920"},"children":[{"type":"text","value":"axios"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-b38898"},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-03d1bd"},"children":[{"type":"text","value":"'axios'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-4fa168"},"children":[{"type":"text","value":"declare"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-4fa168"},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-03d1bd"},"children":[{"type":"text","value":"'vue'"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-4fa168"},"children":[{"type":"text","value":"interface"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-a8d69f"},"children":[{"type":"text","value":"ComponentCustomProperties"}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-08507f"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-5cb2bd"},"children":[{"type":"text","value":"$translate"}]},{"type":"element","tag":"span","props":{"class":"ct-e04799"},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"class":"ct-08507f"},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"class":"ct-71e141"},"children":[{"type":"text","value":"key"}]},{"type":"element","tag":"span","props":{"class":"ct-e04799"},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"class":"ct-08507f"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-2c3ffd"},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"class":"ct-08507f"},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"class":"ct-242aba"},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"class":"ct-08507f"},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"class":"ct-2c3ffd"},"children":[{"type":"text","value":"string"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":" }"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"class":"ct-ce3805"},"children":[{"type":"text","value":"}"}]}]}]}]}]},{"type":"element","tag":"style","children":[{"type":"text","value":".ct-242aba{color:#FF7B72}.ct-2c3ffd{color:#79C0FF}.ct-71e141{color:#FFA657}.ct-e04799{color:#FF7B72}.ct-5cb2bd{color:#D2A8FF}.ct-08507f{color:#C9D1D9}.ct-a8d69f{color:#FFA657}.ct-4fa168{color:#FF7B72}.ct-03d1bd{color:#A5D6FF}.ct-1ce920{color:#C9D1D9}.ct-ce3805{color:#C9D1D9}.ct-b38898{color:#FF7B72}.ct-ba2647{color:#8B949E}.light .ct-ba2647{color:#93A1A1}.light .ct-b38898{color:#859900}.light .ct-ce3805{color:#657B83}.light .ct-1ce920{color:#268BD2}.light .ct-03d1bd{color:#2AA198}.light .ct-4fa168{color:#073642}.light .ct-a8d69f{color:#268BD2}.light .ct-08507f{color:#657B83}.light .ct-5cb2bd{color:#268BD2}.light .ct-e04799{color:#859900}.light .ct-71e141{color:#657B83}.light .ct-2c3ffd{color:#859900}.light .ct-242aba{color:#073642}"}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[]}},"_type":"markdown","_id":"content:Frontend:Vue:Adding global properties to component.md","_source":"content","_file":"Frontend/Vue/Adding global properties to component.md","_extension":"md"} |