Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vue compositon api reusable code reuse code

import { ref, onMounted } from 'vue'
export function useSearchArticles() {
  const articles = ref([])
  const searchParameters = ref([])
  onMounted(() => {
    this.articles = ArticlesAPI.loadArticles()
  })
  const searchArticles = (id) => {
    return articles.filter(() => {
      // some search code
    })
  }
  return {
    articles,
    searchParameters,
    searchArticles,
  }
}
Source by learnvue.co #
 
PREVIOUS NEXT
Tagged: #vue #compositon #api #reusable #code #reuse #code
ADD COMMENT
Topic
Name
6+2 =