{"id":14167,"date":"2023-12-18T06:10:56","date_gmt":"2023-12-18T03:10:56","guid":{"rendered":"https:\/\/elzero.org\/?p=14167"},"modified":"2023-12-18T06:15:37","modified_gmt":"2023-12-18T03:15:37","slug":"add-vuejs-global-property-and-use-it","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/add-vuejs-global-property-and-use-it\/","title":{"rendered":"\u0625\u0636\u0627\u0641\u0629 Global Property \u0644\u062a\u0637\u0628\u064a\u0642 Vuejs"},"content":{"rendered":"<div class=\"text\">\r\n\u0633\u062a\u0642\u0627\u0628\u0644 \u062f\u0627\u0626\u0645\u0627 Function \u062a\u062d\u062a\u0627\u062c \u0623\u0646 \u062a\u0643\u0648\u0646 \u0645\u0639\u0643 \u062f\u0648\u0645\u0627 \u0639\u0644\u0649 \u0645\u0633\u062a\u0648\u0649 \u0627\u0644\u062a\u0637\u0628\u064a\u0642 \u0634\u0627\u0647\u062f \u0645\u0639\u064a \u0627\u0644\u0645\u062b\u0627\u0644 \u0627\u0644\u062a\u0627\u0644\u064a \u0644\u062f\u064a\u0643 \u0647\u0630\u0647 \u0627\u0644 Function \u0627\u0644\u062a\u064a \u062a\u0642\u0628\u0644 \u0645\u0646\u0643 String \u062b\u0645 \u062a\u0642\u0648\u0645 \u0628\u062a\u062d\u0648\u064a\u0644 \u0623\u0648\u0644 \u062d\u0631\u0641 \u0645\u0646\u0647 \u0644 Capital Letter \u0648\u0646\u0631\u064a\u062f \u0623\u0646 \u062a\u0643\u0648\u0646 \u0645\u0639\u0646\u0627 \u062f\u0648\u0645\u0627 \u0641\u064a \u062a\u0637\u0628\u064a\u0642\u0646\u0627 \u0627\u0644\u0645\u0635\u0645\u0645 \u0628\u0648\u0627\u0633\u0637\u0629 Vuejs \u0648\u0644\u0630\u0644\u0643 \u0633\u0648\u0641 \u0646\u062d\u062a\u0627\u062c \u0623\u0646 \u0646\u0636\u064a\u0641 \u0647\u0630\u0647 \u0627\u0644 Function \u0644\u0644 Global Properties \r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nfunction capFirstChar(str) {\r\n  return str.charAt(0).toUpperCase() + str.slice(1);\r\n};\r\n<\/script>\r\n\r\n<div class=\"text\">\r\n\u062f\u0627\u062e\u0644 \u0645\u0644\u0641 main.js \u0642\u0645 \u0628\u0639\u0645\u0644 \u0627\u0644\u062a\u0627\u0644\u064a\r\n<\/div>\r\n\r\n<div class=\"file-name\">main.js<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\n  app.config.globalProperties.$capFirstChar = function capFirstChar(str) {\r\n    return str.charAt(0).toUpperCase() + str.slice(1);\r\n  };\r\n<\/script>\r\n\r\n<div class=\"note\">\r\n\u0644\u0627 \u062a\u0646\u0633\u0649 \u0623\u0646 \u062a\u0642\u0648\u0645 \u0628\u0648\u0636\u0639 \u0627\u0644 Code \u0642\u0628\u0644 \u0639\u0645\u0644 Mount \u0644\u0644 App\r\n<\/div>\r\n\r\n<div class=\"text\">\r\n\u0627\u0644\u0622\u0646 \u064a\u0645\u0643\u0646\u0643 \u0625\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644 Function \u0641\u064a \u0623\u064a \u0645\u0643\u0627\u0646 \u0648\u0623\u0635\u0628\u062d\u062a \u0645\u0646 \u0636\u0645\u0646 \u0627\u0644 Global Properties \u0648\u064a\u0645\u0643\u0646\u0643 \u0623\u0646 \u062a\u0631\u0627\u0647\u0627 \u0627\u0644\u0622\u0646 \u0644\u0648 \u0642\u0645\u062a \u0628\u0637\u0628\u0627\u0639\u0629 \u0627\u0644 app.config \u0641\u064a \u0627\u0644 Console\r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nconsole.log(app.config.globalProperties);\r\n<\/script>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/elzero.org\/old\/wp-content\/uploads\/2023\/12\/vue-global-properties.png\" alt=\"\" \/>\r\n\r\n<div class=\"text\">\r\n\u0627\u0644\u0622\u0646 \u0644\u062a\u0633\u062a\u062e\u062f\u0645\u0647\u0627 \u062f\u0627\u062e\u0644 \u0627\u0644 Views \u0643\u0644 \u0645\u0627 \u0639\u0644\u064a\u0643 \u0639\u0645\u0644 \u0627\u0644\u062a\u0627\u0644\u064a\r\n<\/div>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\n{{ $capFirstChar(user.displayName) }}\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u0625\u0636\u0627\u0641\u0629 Global Property \u0644\u062a\u0637\u0628\u064a\u0642 Vuejs<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1425],"tags":[],"class_list":["post-14167","post","type-post","status-publish","format-standard","hentry","category-vuejs-tutorials"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=14167"}],"version-history":[{"count":5,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14167\/revisions"}],"predecessor-version":[{"id":14173,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/14167\/revisions\/14173"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=14167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=14167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=14167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}