Answer the question
In order to leave comments, you need to log in
Why isn't computed working in vue3?
<script>
function setWidth(width) {
if (width > 1600) return "xlg-max";
else if (width < 1600 && width > 1366) return "xlg";
else if (width < 1366 && width > 1280) return "lg";
else if (width < 1280 && width > 1024) return "md";
else if (width < 1024 && width > 768) return "tablet";
else if (width < 768 && width > 480) return "sm";
else if (width < 480) return "xs";
}
import { onMounted, provide, reactive, computed } from "vue";
import { useStore } from "vuex";
export default {
name: "App",
setup() {
let windowSize = reactive({
width: 0,
breakpoint: null,
});
provide("windowSize", windowSize);
function setWindowSize() {
windowSize.breakpoint = setWidth(window.innerWidth);
windowSize.width = window.innerWidth;
}
onMounted(() => {
setWindowSize();
window.addEventListener("resize", setWindowSize);
});
const store = useStore();
store.dispatch("boards/getBoards").then((event) => console.log(event));
const boards = computed(() => {
return store.getters["boards/getBoards"];
});
return boards;
},
};
</script>
Answer the question
In order to leave comments, you need to log in
setup() {
...
const boards = computed(() => {
return store.getters["boards/getBoards"];
});
return boards;
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question