@@ -67,11 +67,10 @@ let searchBarClientHeight = 0;
6767export default {
6868 name: " job" ,
6969 data () {
70- const { keyword = " " , job_category_id = " " } = this .$route .params ;
7170 return {
72- searchKeyword: keyword ,
71+ searchKeyword: " " ,
7372 currentPage: 1 ,
74- job_category_id_list: job_category_id ? [job_category_id] : [],
73+ job_category_id_list: [],
7574 jobCategories: [],
7675 jobCities: [],
7776 location_code_list: [],
@@ -83,6 +82,12 @@ export default {
8382 };
8483 },
8584
85+ activated () {
86+ this .searchKeyword = this .$route .params .keyword || " " ;
87+ if (this .$route .params .job_category_id ) {
88+ this .job_category_id_list = [this .$route .params .job_category_id ];
89+ }
90+ },
8691 created () {
8792 const jobConfigRequest = this .request
8893 .get (" /job-filters" )
@@ -104,19 +109,21 @@ export default {
104109 positionY = this .$refs .searchBar .offsetTop ;
105110 searchBarClientHeight = this .$refs .searchBar .clientHeight ;
106111 });
112+ },
113+ activated () {
107114 const onPageScroll = () => {
115+
108116 const top = this .$refs .searchBar .getBoundingClientRect ().top ;
109117
110118 this .searchBarFixedTop =
111119 window .scrollY > positionY - searchBarClientHeight / 2 ;
112120 };
113121 window .addEventListener (" scroll" , onPageScroll);
114122
115- this .$once (" hook:destroyed " , () => {
123+ this .$on (" hook:deactivated " , () => {
116124 window .removeEventListener (" scroll" , onPageScroll);
117125 });
118126 },
119-
120127 computed: {
121128 queryFilter () {
122129 return {
@@ -135,7 +142,7 @@ export default {
135142 },
136143 watch: {
137144 queryFilter : function (newVal , oldVal ) {
138- newVal . offset !== oldVal . offset && window .scrollTo (0 , positionY);
145+ this . searchBarFixedTop && window .scrollTo (0 , positionY);
139146 this .fetchList ();
140147 }
141148 },
0 commit comments