21.01.06 ajax 통신 연계 통한 블로그 게시물 검색 페이지 생성(+인덱스 게시판 디자인 개편)
2021. 1. 6. 22:23ㆍJAVA/Blog 사이트 프로젝트
<search.js>
console.clear();
const articleList = [];
const apiURL = 'article_list.json';
$.get(
apiURL,
{},
function(data) {
data.forEach((row, index) => {
const article = {
id:row.id,
regDate:row.regDate,
writer:row.extra_memberName,
title:row.title,
body:row.body
};
articleList.push(article);
});
},
'json'
);
const articleListBox = new Vue({
el:"#article-search-section",
data:{
articleList:articleList,
keyword:''
},
methods:{
source:_.debounce(function(event){
this.keyword = event.target.value;
}, 500)
},
computed:{
filteredKeyword:function(){
return this.keyword.toLowerCase();
},
filtered:function(){
if(this.filteredKeyword.length == 0){
return this.articleList;
}
return this.articleList.filter((row)=>{
const keys = ['title', 'writer', 'body', 'regDate'];
const match = keys.some((key)=>{
if(row[key].toLowerCase().indexOf(this.filteredKeyword) > -1){
return true;
}
});
return match;
});
}
}
});
<search 페이지>
Dev_J의 BLOG
Dev_J의 BLOG입니다.
blog.devj.me
'JAVA > Blog 사이트 프로젝트' 카테고리의 다른 글
21.01.13 상세페이지 markup 입력시 오류 수정 및 private, setter, getter 도입 (0) | 2021.01.13 |
---|---|
21.01.05 템플릿에 검색어 구현 연습 (0) | 2021.01.05 |
20.12.31 GoogleAnalytics API 도입 테스트(feat.Maven) (0) | 2020.12.31 |
20.12.30 Disqus api 적용 - 댓글수, 추천수 동기화 기능 추가( + 이모지 적용)(feat.jackson) (0) | 2020.12.30 |
20.12.27 사이트 메타태그 적용(상세페이지 내용 나오게 하기 등) (0) | 2020.12.27 |