ROBOT |
ロボスタ |
空中ディスプレイに関する意識調査 導入して欲しい場所の1位は「コンビニやスーパーのセルフレジ」、連想するSF映画の1位は… |
https://robotstart.info/2022/08/06/aerial-display-survey.html
|
空中ディスプレイに関する意識調査導入して欲しい場所の位は「コンビニやスーパーのセルフレジ」、連想するSF映画の位は…シェアツイートはてブ新型コロナウイルスの感染者数が全国的に再び拡大しつつある。 |
2022-08-06 11:34:30 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
M1 Macのローカルでjest-dynamodbを使ってテストする |
https://qiita.com/Michinosuke/items/8b438022a8c0aa1c718a
|
dynamodb |
2022-08-06 20:48:58 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
ホストPC(Ubuntu 22.04)をアップグレードしたらJupyterがクラッシュした話と対処法 |
https://qiita.com/ryoma-jp/items/f4fa17ffb0ef73768c07
|
tensorflowtensorflowlates |
2022-08-06 20:59:49 |
Linux |
CentOSタグが付けられた新着投稿 - Qiita |
GitHub備忘録[次心編] |
https://qiita.com/king_dog_fun/items/e24db7832deb0077fcf6
|
github |
2022-08-06 20:03:29 |
技術ブログ |
Developers.IO |
AWS Microservice Extractor for .NET の解析時に自動でノードタイプを推奨表示してくれるようになりました |
https://dev.classmethod.jp/articles/2022-08-aws-microservice-extractor-net-automated-refactoring-recommendations/
|
awsreinvent |
2022-08-06 11:18:16 |
海外TECH |
DEV Community |
How to use NuxtJS in your next Vue.js project |
https://dev.to/adetutu777/how-to-use-nuxtjs-in-your-next-vuejs-project-272p
|
How to use NuxtJS in your next Vue js project IntroductionHi there have you been thinking of how and when to start using NuxtJS to develop amazing vue applications Alright i ll take that as a yes kindly grab a seat amp ride with me Prerequisite gt Vue jsIn this article we ll demonstrate how to get started with NuxtJS amp talk about the basic things required of you to know Here is a list of what we will be covering Chapter Setting up NuxtJS Chapter Nuxt Composition API Chapter Project Chapter How to use vee validate with NuxtJS Chapter Lazy loading component Chapter Deployment to Netlify Chapter Conclusion Chapter Setting up NuxtJSNuxtJS is an intuitive open source framework which comes with simplicity thereby helping in increasing productivity to get things done faster amp delivering high performance server side rendered web application with a focus on better developer experience For more info on NuxtJS check here NuxtJSFor this article we ll be developing an address book To get started we start by installing NuxtJS also we will be using Boostrapvue CSS framework with it To install NuxtJS run the following commandyou can either use npm or yarn for package installation for this tutorial let s use yarn yarn create nuxt app project name Project name here refers to the title you want to give your project Here is what it looks like on my cmd After installing all dependencies we can then navigate into the code editor and start the development server by running the code belowyarn devThe image below shows what a NuxtJS project folder looks like Chapter Composition ApiNuxtJS composition API can be use with Vue It provides a way to use the Vue Composition API with Nuxt specific featuresTo use the Composition API you run the command shown below on your vscode terminalyarn add nuxtjs composition apiAfter installing composition API the next step is to get it added to the buildModules in your nuxtconfig js file You can check here for more information Composition APIbuildModules nuxtjs composition api module Chapter ProjectNow that we have installed all we needed lets get started We ll be building an app It s an address book app The first thing we will be doing is to create our routes To create a new route in NuxtJS all you need to do is to create your file under the pages directory NuxtJS will take care of all the routing configurations underneath for you In our case we will be creating three pages which are going to be called about account amp contact For each of the pages I ve created an index vue file where our code is going to be written The pages are shown below Also in the component folder we ll be creating a sidebar and a Navbar component Starting with the sidebar the template section consists of a div with class name sidebar the div contain three NuxtLink this is what is going to be used for the redirection to various route the pages created above is what is been passed into the to props In addition NuxtJS comes with a styling class that give styling to active classes In the code below there is a class in style section with name a nuxt link exact active it has a background color and color styling attached to it which get applied to any active pages the user clicked on The sidebar vue component code is shown below Sidebar vue code lt template gt lt div gt lt div class head text my ml px py gt lt h class pt gt AddressBook lt h gt lt div gt lt div class sidebar ml text light gt lt NuxtLink class sidebar list to contact gt Contact lt NuxtLink gt lt br gt lt NuxtLink class sidebar list to account gt Account lt NuxtLink gt lt br gt lt NuxtLink class sidebar list to about gt About lt NuxtLink gt lt br gt lt div gt lt div gt lt template gt lt script gt export default lt script gt lt style scoped gt sidebar height vh width rem padding rem line height font size px background fff head text background fff sidebar list color black padding rem border radius px padding left rem text decoration none a nuxt link exact active color white background B display inline block width lt style gt Now that we have created our sidebar lets go ahead amp create our Navbar the Navbar is taken from bootstrap vue website you can check into the bootstrap website to choose your desired The navbar code is illustrated below lt template gt lt div gt lt div gt lt b navbar toggleable lg class ml nav text mt type light gt lt b navbar brand href gt NavBar lt b navbar brand gt lt b navbar toggle target nav collapse gt lt b navbar toggle gt lt b collapse id nav collapse is nav gt lt b navbar nav gt lt b nav item href gt Link lt b nav item gt lt b navbar nav gt lt Right aligned nav items gt lt b navbar nav class ml auto gt lt b nav form gt lt b form input size sm class mr sm placeholder Search gt lt b form input gt lt b button size sm class my my sm type submit gt Search lt b button gt lt b nav form gt lt b nav item dropdown right gt lt b dropdown item href gt Profile lt b dropdown item gt lt b dropdown item href gt Sign Out lt b dropdown item gt lt b nav item dropdown gt lt b navbar nav gt lt b collapse gt lt b navbar gt lt div gt lt div gt lt template gt lt script gt export default lt script gt lt style scoped gt nav text background fff lt style gt Let s take a look at the output below before that at the root folder of our pages I have deleted the tutorial component that comes pre installed with NuxtJS amp also deleted it from the component folder Right now what we have in the root folder is a lorem text check out the output below Contact PageThe Contact page is a page with an index vue file and inside this file there is a component with name Address vue The Address vue component is where we going to write our codes The contact page index vue code is shown below contact page index vue code lt template gt lt div style display flex gt lt Address class mx gt lt div gt lt template gt lt script gt import Address from components Address vue export default components Address lt script gt lt style scoped gt lt style gt In the template folder of our Address component we have two input fields the b form input are gotten from bootstrapvue website with a Save button Each of the form input have their respective v model In the script folder we start by importing ref from NuxtJS followed by the codes to solve the problem The code is shown below Address vue component code lt template gt lt div class my address gt lt h class address title mt gt Address book lt h gt lt div class mt gt lt form gt lt b form input placeholder Name v model name gt lt b form input class mt placeholder Phone number v model numbers gt lt b button click saveMessage disabled invalid class mt address btn variant info gt Save lt b button gt lt form gt lt div gt lt div class contact list mt gt lt h gt Contact List lt h gt lt div class d flex justify content between user info p mt v for results in result key results gt lt div class gt results name lt div gt lt div class gt results numbers lt div gt lt div gt lt div gt lt div gt lt template gt lt script gt import ref from nuxtjs composition api export default name Address setup const name ref const numbers ref const result ref const done ref false const saveMessage gt const message name name value numbers numbers value result value push message name value numbers value done value true return name numbers saveMessage result done lt script gt lt style scoped gt my address width rem address btn border px solid green user info background rgb border radius px lt style gt The output of the contact page is shown below Contact page Chapter How to use vee validate with NuxtJSLets talk about how to use vee validate to enforce user to input in the required before submitting our forms To do this in NuxtJS we start by installing vee validate amp then run this on the terminalyarn add vee validate After doing this the next step is to add the vee validate rules to the buildModules in the NuxtJS config files You can check here for more info vee validate with Nuxtjs Adding vee validate to the NuxtJS config filesbuild transpile vee validate dist rules You can extend webpack config here extend config ctx Having done the following we can now choose from the vee validate available rules and get them applied to our code For our use case we will be using the required alpha amp numeric rule Firstly we will create a folder called plugins amp inside the folder we ll create a file called vee validate js Inside the vee validate js file is where we ll import all the rules we ll be needing check below to see code vee validate jsimport extend from vee validate import required numeric alpha from vee validate dist rules extend required required message This field is required extend numeric numeric message The field may only contain numbers extend alpha alpha message The field may only contain alphabetic letters Secondly we ll add the plugin path to the NuxtJS config pluginsplugins plugins vee validate js After following the steps above we can now make use of the rules globally in our codeFor our first input field we ll be using the required rule telling the user that its compulsory to fill their details amp also the alpha rules telling the user only alphabet characters can be typed in As for the second input field we ll be using the required rule along side the numeric rules telling the users it is important to fill there details and its only numbers that is allowed Going back to our Address vue component we start by importing the ValidationProvider ValidationObserver from vee validate followed by adding them to the component in the script folder amp returning them in the setup Having done this the next thing to be done is to wrap the form element with ValidationObserver Each of the input fields is to be wrapped with validationProvider amp the rules After the form input is a div with span attribute the span is the error msg to be displayed if the user didn t obey any of the validation rules On each of the input fields we have a v on keyup resetDone the resetDone function is to take off the error msg after submitting our forms Also our button has a disabled prop with invalid passed to it The invalid is coming from vee validate this is going to disable the button making it unclickable until the user passes every of the validation rules set to it Code is shown below lt template gt lt div class my address gt lt h class address title gt Address book lt h gt lt div class mt gt lt ValidationObserver v slot invalid gt lt form gt lt ValidationProvider rules required alpha v slot errors gt lt b form input v on keyup resetDone placeholder Name v model name gt lt div class style position relative padding bottom rem gt lt span v if done style color red position absolute left gt errors lt span gt lt div gt lt ValidationProvider gt lt ValidationProvider rules required numeric v slot errors gt lt b form input v on keyup resetDone class mt placeholder Phone number v model numbers gt lt div class style position relative padding bottom rem gt lt span v if done style color red position absolute left gt errors lt span gt lt div gt lt ValidationProvider gt lt b button click saveMessage disabled invalid class mt address btn variant info gt Save lt b button gt lt form gt lt ValidationObserver gt lt div gt lt div class contact list mt gt lt h gt Contact List lt h gt lt div class d flex justify content between user info p mt v for results in result key results gt lt div class gt results name lt div gt lt div class gt results numbers lt div gt lt div gt lt div gt lt div gt lt template gt lt script gt import ref from nuxtjs composition api import ValidationProvider ValidationObserver from vee validate export default name Address components ValidationProvider ValidationObserver setup const name ref const numbers ref const result ref const done ref false const saveMessage gt const message name name value numbers numbers value result value push message name value numbers value done value true resetDone if this done false return this done false const resetDone gt if done value false return return name numbers saveMessage result done resetDone lt script gt lt style scoped gt my address width rem address title margin top rem address btn border px solid green user info background rgb border radius px lt style gt Output is shown belowThe output below shows different error state as passed into our code also the button is disabled amp get enabled only when user has obey the validation rules Chapter Lazy Loading componentLets talk about lazy loading LazyLoading is a good way of reducing less API calls until a user really needs to Imagine having about API calls to mount at the same time this can really slow down your application the best thing is to lazy load the components until when the page is been clicked on In this tutorial we ll be lazyloading the about vue page In the index vue of the about page we have our AboutPage vue component attached To lazyLoad this all you need do is add Lazy at the front of the AboutPage component There is a v if with name show attached to the component amp also a function showData attached to the button In our script folder our show is set to false by default and in the showData function we turn it true which means that its only when that button is been clicked that it should make the API calls Code is shown below about page index vue lt template gt lt div gt lt div class ml mt gt lt h gt Hello World lt h gt lt b button click showData class mt variant info gt Click Me lt b button gt lt div gt lt div v if show gt lt LazyAboutPage gt lt div gt lt div gt lt template gt lt script gt import ref from vue composition api export default setup const show ref false const showData gt show value true return show showData lt script gt lt style scoped gt lt style gt The AboutPage vue component is where we call an endpoint this endpoint is gotten from JSON Placeholder link can be found here fake Json api Code is attached below lt template gt lt div gt lt div class row ml gt lt div class col md mt v for todos in todo key todos id gt lt div class card todo card mt p gt todos username lt div gt lt div gt lt div gt lt div gt lt template gt lt script gt import axios from axios import ref useFetch from nuxtjs composition api export default setup const todo ref useFetch async gt await axios get then response gt todo value response data catch error gt console log error return todo lt script gt lt style scoped gt todo card border px solid rgb lt style gt A snippet of our network tab before and after the API is called is displayed below Before clicking our buttonIn our about vue page our network tab only had request on first mount meaning that it hasn t make the API call remember we have lazy load the component meaning its until when the button is been clicked before it makes the API call After clicking the buttonNow that the button has been clicked it then makes the API request now showing total of request Lazy Loading is a really a great way to improving the performance of your code Here is the output of the about vue page Image Full output Also we have the account page Before I talk about the account page lets talk about how to make our sidebar appears on every pages clicked on To do this we ll create a folder named layouts this is from NuxtJS Inside our layout folder we create a file name default vue Here is where we are going to import our sidebar and navbar components into Whatever is been called in the default page is definitely going to be applicable through out the application There is a lt Nuxt gt at the end of our mainnav div this is the entry point of our application in NuxtJs layouts gt gt default vue lt template gt lt div class wrapper style display flex gt lt Sidebar gt lt div class gt lt div class nav title gt lt MainNav gt lt div gt lt Nuxt gt lt div gt lt div gt lt template gt lt script gt export default lt script gt lt style scoped gt wrapper background eee nav title width calc vw rem lt style gt Back to our account page Account page isn t different from the rest of the page but on this page we don t want neither the navbar or sidebar to show There are instance where you don t want a certain style which is already passed to the layout folder to be applicable to a page e g login page amp that s what we want to achieve with this page To achieve this we create a file under the layout directory we ll name it no sidenav vue Inside the file we won t be adding the sidebar and navbar as it is in the layout The code is shown below lt template gt lt div class gt lt Nuxt gt lt div gt lt template gt lt script gt export default setup lt script gt Now we can make use of it in the account page all we need do is to add the no sidenav to the layout in the script section Code is shown below account vue lt template gt lt div gt lt h class text center mt gt Account page lt h gt lt div gt lt template gt lt script gt export default layout no sidenav lt script gt lt style scoped gt lt style gt The output is shown below Chapter Deployment to NetlifyTo deploy to netlify we ll go ahead and edit the build settings in our netlify dashboard As shown below Chapter ConclusionThis tutorial has walk us through on how to use NuxtJS to develop amazing Vue projects The GitHub link code can be found here Thanks for reading happyCoding |
2022-08-06 11:04:40 |
海外ニュース |
Japan Times latest articles |
Japan’s top envoy promises Tokyo will help ASEAN with Myanmar issue |
https://www.japantimes.co.jp/news/2022/08/06/national/politics-diplomacy/yoshimasa-hayashi-hun-sen-myanmar/
|
Japan s top envoy promises Tokyo will help ASEAN with Myanmar issueDuring a meeting with Cambodia s prime minister Yoshimasa Hayashi expressed serious concern about executions of four Myanmar people including two pro democracy activists |
2022-08-06 20:06:32 |
海外ニュース |
Japan Times latest articles |
Fight or surrender: Taiwan’s generational divide on China’s threats |
https://www.japantimes.co.jp/news/2022/08/06/asia-pacific/taiwan-generation-gap-china/
|
Fight or surrender Taiwan s generational divide on China s threatsConflicting allegiances dominate Taiwan politics with debates over China breaking down along the lines of age identity and geography |
2022-08-06 20:00:59 |
ニュース |
BBC News - Home |
Croatia bus crash: Twelve Polish pilgrims killed and 31 injured |
https://www.bbc.co.uk/news/world-europe-62448062?at_medium=RSS&at_campaign=KARANGA
|
lives |
2022-08-06 11:06:35 |
ニュース |
BBC News - Home |
Cyclists who kill pedestrians could face tougher sentences |
https://www.bbc.co.uk/news/uk-62444889?at_medium=RSS&at_campaign=KARANGA
|
current |
2022-08-06 11:34:58 |
ニュース |
BBC News - Home |
Brighton Pride 2022: Festival celebrates 30th anniversary |
https://www.bbc.co.uk/news/uk-england-sussex-62441276?at_medium=RSS&at_campaign=KARANGA
|
aguilera |
2022-08-06 11:14:18 |
ニュース |
BBC News - Home |
Commonwealth Games: Wales' Gemma Frizelle wins gold in rhythmic gymnastics hoop final |
https://www.bbc.co.uk/sport/commonwealth-games/62448588?at_medium=RSS&at_campaign=KARANGA
|
Commonwealth Games Wales x Gemma Frizelle wins gold in rhythmic gymnastics hoop finalWales Gemma Frizelle wins a gold in the rhythmic gymnastics hoop final in her second appearance at the Commonwealth Games |
2022-08-06 11:52:29 |
ニュース |
BBC News - Home |
Manchester City: Erling Haaland's dream is to win Champions League, he tells Alan Shearer |
https://www.bbc.co.uk/sport/football/62430718?at_medium=RSS&at_campaign=KARANGA
|
Manchester City Erling Haaland x s dream is to win Champions League he tells Alan ShearerOne great goalscorer interviews another as Alan Shearer speaks with Erling Haaland for Football Focus before the Manchester City striker makes his Premier League debut |
2022-08-06 11:00:57 |
ニュース |
BBC News - Home |
Commonwealth Games: Jack Laugher scrapes through to 3m springboard final |
https://www.bbc.co.uk/sport/commonwealth-games/62448416?at_medium=RSS&at_campaign=KARANGA
|
springboard |
2022-08-06 11:31:40 |
北海道 |
北海道新聞 |
西1―2ロ(6日) ロッテ、連敗3で止める |
https://www.hokkaido-np.co.jp/article/715075/
|
連敗 |
2022-08-06 20:35:00 |
北海道 |
北海道新聞 |
息子名乗る男らに250万円だまし取られる 札幌の70代男性 |
https://www.hokkaido-np.co.jp/article/715074/
|
札幌市白石区 |
2022-08-06 20:30:00 |
北海道 |
北海道新聞 |
鈴鹿8耐で転倒、意識不明 フリー走行中の英国人選手 |
https://www.hokkaido-np.co.jp/article/715071/
|
三重県鈴鹿市稲生 |
2022-08-06 20:29:00 |
北海道 |
北海道新聞 |
国内で22万7563人感染 152人死亡、新型コロナ |
https://www.hokkaido-np.co.jp/article/715070/
|
新型コロナウイルス |
2022-08-06 20:26:00 |
北海道 |
北海道新聞 |
車発見も男性不明のまま、山形 飯豊町、捜索続行 |
https://www.hokkaido-np.co.jp/article/715068/
|
山形県飯豊町 |
2022-08-06 20:21:00 |
北海道 |
北海道新聞 |
京都国際5―6一関学院 一関学院がサヨナラ勝ち |
https://www.hokkaido-np.co.jp/article/715067/
|
一関学院 |
2022-08-06 20:15:00 |
北海道 |
北海道新聞 |
韓国・陜川でも被爆者の慰霊式 日米へ責任訴え |
https://www.hokkaido-np.co.jp/article/715066/
|
原爆投下 |
2022-08-06 20:15:00 |
北海道 |
北海道新聞 |
飲食・宿泊業で人手不足 コロナ禍で就職に二の足、道外から人材確保も |
https://www.hokkaido-np.co.jp/article/715057/
|
人手不足 |
2022-08-06 20:06:01 |
コメント
コメントを投稿